Skip to content

Commit 58d67f8

Browse files
mondorealeCopilot
andauthored
refactor: Enable noImplicitOverride on the remaining non-generated code (#3304)
This pull request refactors TypeScript configuration across multiple packages to improve handling of generated code and project references, and updates some package scripts for consistency. It also includes minor code improvements for clarity and correctness. > [!NOTE] > Previously, `noImplicitOverride` was explicitly set to `false` across the app. This was not a design choice, but a workaround: the auto-generated protobuf types were incompatible with `noImplicitOverride`, and there was no proper isolation at the tsconfig level to scope that limitation. As a result, stricter typing guarantees were relaxed globally. > > Changes in this PR are the remaining step towards bringing the restriction back, making the types stricter again. ### Changes **TypeScript configuration improvements:** * Introduced separate `tsconfig.generated.json` files in several packages (such as `autocertifier-client`, `dht`, `proto-rpc`, and `sdk`) to isolate generated code and manage its compilation independently. These are now referenced in the main and test TypeScript configs. [[1]](diffhunk://#diff-9950b7b77c8a7db18e0ef901b107025b666a0e0a27a436616b43c2fedb34d6c1R1-R10) [[2]](diffhunk://#diff-de621a41125dd18f6388b50a2ec6281e3b8fa498b793969c76dc0a8d8531f68aR1-R11) [[3]](diffhunk://#diff-eab3f7cef1e6788318415e3df2a580ecfc85bf2902a773843b518ba10da07d45R1-R10) * Updated `tsconfig.json` and `tsconfig.jest.json` files to remove `noImplicitOverride: false` (now set only in generated configs), exclude generated directories from main source includes, and add references to the new generated configs. [[1]](diffhunk://#diff-ae13578e8d026eec67d6b00c439076ab2fc27081e16cb0744b996b414ec28a98L4-R11) [[2]](diffhunk://#diff-70012901c7a9586d8be81a0f0a58cf6545215824aa31d03c4933123d0df69280L4-R16) [[3]](diffhunk://#diff-57fd489a6641c04408b02f51816e203938c2d4d819f96f2aee228814678e7d9fL3-R10) [[4]](diffhunk://#diff-1f70c1f766410506b8ac4d72e9e2cdf43c0dd3a95837202876180763d02093e2L3-R11) [[5]](diffhunk://#diff-62ec9179a1fd352f07b1db2aae889fa66e81cf7f72ceffe25ae527ff7ad6c492L8-R23) [[6]](diffhunk://#diff-24db07be3ce94f0c29f9b1cdb5eb169b812640e615757b63168ec8eb28d605c6L6-R6) [[7]](diffhunk://#diff-24db07be3ce94f0c29f9b1cdb5eb169b812640e615757b63168ec8eb28d605c6R18-R22) [[8]](diffhunk://#diff-ae13578e8d026eec67d6b00c439076ab2fc27081e16cb0744b996b414ec28a98L4-R11) **Project reference and dependency cleanup:** * Reordered and clarified project references in several `tsconfig.json` files to ensure correct dependency resolution and build order. [[1]](diffhunk://#diff-6911c66f995472db595934d34bed8bb3b9d4f5f4e8dcef1329a16d498928e684R11-R14) [[2]](diffhunk://#diff-38daa775ecafcf440e7c2b9817052481019197dfba8e0bbb482e7ce5efe0cfafR13-R16) [[3]](diffhunk://#diff-62ec9179a1fd352f07b1db2aae889fa66e81cf7f72ceffe25ae527ff7ad6c492L8-R23) [[4]](diffhunk://#diff-70012901c7a9586d8be81a0f0a58cf6545215824aa31d03c4933123d0df69280L4-R16) [[5]](diffhunk://#diff-ae13578e8d026eec67d6b00c439076ab2fc27081e16cb0744b996b414ec28a98L4-R11) **Package script updates:** * Changed the `check` script in several `package.json` files to use `tsc -b` (build mode) instead of `tsc -p`, aligning with project references and improving type checking. [[1]](diffhunk://#diff-48deceddbbe98a41ff1d0f560db132548031fbd96d790c09ffeed924a20e8a05L29-R29) [[2]](diffhunk://#diff-e81a3463e3e75e879c7fa17b1609d29d02bb633aaceb777564c9f88a48729ff9L24-R24) [[3]](diffhunk://#diff-77164cc5c071d1488e1cf72c0f91fdd99dd8976edb5004c83198bbd517039572L39-R39) [[4]](diffhunk://#diff-e73f8b6abf767f5f6271d1dcbf5188b40d63732e6a8cd772b44f677c2fc36bc1L23-R23) **Minor code improvements:** * Added `override` keyword to overridden methods in test and implementation files for better type safety and clarity. [[1]](diffhunk://#diff-5e6ebf26c1a7f17946b4a79009d4c286b6a553a215db065393b9f0e32f81dab0L20-R20) [[2]](diffhunk://#diff-f03278bf6d70079d4859c692194a7896c0ef0270919070d88bd9a739979cf4c5L65-R65) [[3]](diffhunk://#diff-f03278bf6d70079d4859c692194a7896c0ef0270919070d88bd9a739979cf4c5L93-R93) [[4]](diffhunk://#diff-0c8af68961e03aa39330bdcca6e9201cc7421497e5dfe3fb4eddfd62b358e22aL29-R29) --------- Co-authored-by: Copilot <[email protected]>
1 parent 36fca2b commit 58d67f8

23 files changed

+102
-51
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"noImplicitOverride": false
5+
},
6+
"include": [
7+
"generated"
8+
],
9+
"exclude": []
10+
}
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
{
22
"extends": "../../tsconfig.node.json",
33
"compilerOptions": {
4-
"outDir": "dist",
5-
"noImplicitOverride": false
4+
"outDir": "dist"
65
},
76
"include": [
8-
"src",
9-
"generated"
7+
"src"
108
],
119
"references": [
12-
{ "path": "../utils" }
10+
{ "path": "../utils" },
11+
{ "path": "./tsconfig.generated.json" }
1312
]
1413
}

packages/autocertifier-server/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"bin"
99
],
1010
"references": [
11+
{ "path": "../utils" },
1112
{ "path": "../autocertifier-client" },
12-
{ "path": "../dht" },
1313
{ "path": "../proto-rpc" },
14-
{ "path": "../utils" }
14+
{ "path": "../dht" }
1515
]
1616
}

packages/cli-tools/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"bin"
1111
],
1212
"references": [
13+
{ "path": "../utils" },
1314
{ "path": "../dht" },
14-
{ "path": "../sdk" },
1515
{ "path": "../trackerless-network" },
16-
{ "path": "../utils" }
16+
{ "path": "../sdk" }
1717
]
1818
}

packages/dht/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"postbuild": "./scripts/postbuild.sh",
2727
"build": "tsc -b",
2828
"build-browser": "webpack --mode=development --progress",
29-
"check": "tsc -p tsconfig.jest.json",
29+
"check": "tsc -b tsconfig.jest.json",
3030
"clean": "jest --clearCache --config '{}' || true; rm -rf dist generated *.tsbuildinfo node_modules/.cache || true",
3131
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
3232
"test": "npm run test-unit && npm run test-integration && npm run test-end-to-end",

packages/dht/test/unit/PeerManager.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const createDhtNodeRpcRemote = (
1717
) => {
1818
const remote = new class extends DhtNodeRpcRemote {
1919
// eslint-disable-next-line class-methods-use-this
20-
async ping(): Promise<boolean> {
20+
override async ping(): Promise<boolean> {
2121
return !pingFailures.has(toNodeId(peerDescriptor))
2222
}
2323
}(localPeerDescriptor, peerDescriptor, undefined as any, new MockRpcCommunicator())

packages/dht/test/utils/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const createMockRingNode = async (
6262
rpcRequestTimeout: 5000
6363
}
6464
const node = new class extends DhtNode {
65-
async stop(): Promise<void> {
65+
override async stop(): Promise<void> {
6666
await super.stop()
6767
await mockConnectionManager.stop()
6868
}
@@ -90,7 +90,7 @@ export const createMockConnectionDhtNode = async (
9090
rpcRequestTimeout: 5000
9191
}
9292
const node = new class extends DhtNode {
93-
async stop(): Promise<void> {
93+
override async stop(): Promise<void> {
9494
await super.stop()
9595
await mockConnectionManager.stop()
9696
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"noImplicitOverride": false
5+
},
6+
"include": [
7+
"generated"
8+
],
9+
"exclude": []
10+
}

packages/dht/tsconfig.jest.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
{
22
"extends": "../../tsconfig.jest.json",
3-
"compilerOptions": {
4-
"noImplicitOverride": false
5-
},
63
"include": [
74
"src",
8-
"generated",
95
"test",
106
"package.json",
117
"scripts"
8+
],
9+
"references": [
10+
{ "path": "./tsconfig.generated.json" }
1211
]
1312
}

packages/dht/tsconfig.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
{
22
"extends": "../../tsconfig.node.json",
33
"compilerOptions": {
4-
"outDir": "dist",
5-
"noImplicitOverride": false
4+
"outDir": "dist"
65
},
76
"include": [
87
"src",
9-
"generated",
108
"package.json"
119
],
1210
"references": [
13-
{ "path": "../autocertifier-client" },
11+
{ "path": "../utils" },
12+
{ "path": "../proto-rpc" },
1413
{ "path": "../cdn-location" },
1514
{ "path": "../geoip-location" },
16-
{ "path": "../proto-rpc" },
17-
{ "path": "../utils" }
15+
{ "path": "../autocertifier-client" },
16+
{ "path": "./tsconfig.generated.json" }
1817
]
1918
}

0 commit comments

Comments
 (0)