Skip to content

Commit b3f5f3e

Browse files
authored
feat: simplify tsconfig.json (#1538)
* chore: update ignore files * feat: simplify tsconfig.json * feat: simplify projects/burnr/tsconfig.json * feat: simplify projects/demo/tsconfig.json * feat: simplify projects/extension/tsconfig.json * feat: update project build script * fix: remove verbatimModuleSyntax * fix: connet esm/cjs tsconfig.json
1 parent 31237ce commit b3f5f3e

File tree

18 files changed

+77
-119
lines changed

18 files changed

+77
-119
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"deep-clean": "yarn workspaces foreach run deep-clean && rm -rf node_modules",
2929
"clean": " yarn workspaces foreach run clean",
3030
"lint": "prettier --check . && yarn workspaces foreach run lint",
31-
"build": "yarn workspaces foreach run build",
31+
"build": "yarn workspaces foreach --topological run build",
3232
"test": "yarn workspaces foreach run test",
3333
"dev:api-docs": "concurrently -n typedoc,http-server 'nodemon -e ts --watch ./packages/connect --watch ./packages/connect-extension-protocol --exec typedoc --entryPoints ./packages/connect/src/index.ts --entryPoints ./packages/connect-extension-protocol/src/index.ts' 'http-server _site/api'",
3434
"dev:burnr": "yarn workspace @substrate/burnr run dev",

packages/connect-extension-protocol/tsconfig-cjs.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"compilerOptions": {
44
"module": "commonjs",
55
"outDir": "./dist/cjs",
6-
"target": "es2015"
7-
}
6+
"target": "es2015",
7+
"noEmit": false
8+
},
9+
"include": ["src"]
810
}

packages/connect-extension-protocol/tsconfig-mjs.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"compilerOptions": {
44
"module": "es2020",
55
"outDir": "./dist/mjs",
6-
"target": "es2018"
7-
}
6+
"target": "es2018",
7+
"noEmit": false
8+
},
9+
"include": ["src"]
810
}
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
{
22
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
4-
"allowSyntheticDefaultImports": true,
5-
"baseUrl": ".",
6-
"rootDir": "./src",
7-
"esModuleInterop": true,
8-
"moduleResolution": "node",
9-
"resolveJsonModule": true,
10-
"skipLibCheck": true,
11-
"strict": true,
4+
"composite": true,
5+
"rootDir": "src",
126
"downlevelIteration": true
137
}
148
}

packages/connect/.eslintignore

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# don't ever lint node_modules
2+
23
node_modules
4+
35
# don't lint build output (make sure it's set to your correct build folder name)
6+
47
dist
58
coverage
9+
610
# don't lint .cache
11+
712
.chains
813

9-
src/connector/specs/*.json
10-
src/connector/specs/js/*.ts
14+
src/connector/specs/_.json
15+
src/connector/specs/js/_.ts

packages/connect/src/connector/extension.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import { it, describe, expect } from "vitest"
55
import { randomBytes } from "crypto"
66
import {
7-
ToApplication,
8-
ToExtension,
7+
type ToApplication,
8+
type ToExtension,
99
} from "@substrate/connect-extension-protocol"
1010
import { createScClient } from "./extension"
1111
import { AlreadyDestroyedError, CrashError } from "./types"
@@ -22,7 +22,7 @@ if (!globalThis.crypto) {
2222
tmp.set(randomBytesBuffer)
2323
const test = new DataView(arr.buffer)
2424
for (let i = 0; i < tmp.length; i++) {
25-
test.setUint8(i, tmp[i])
25+
test.setUint8(i, tmp[i]!)
2626
}
2727
return arr
2828
},

packages/connect/src/connector/extension.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import {
66
AlreadyDestroyedError,
77
CrashError,
88
JsonRpcDisabledError,
9-
Chain,
10-
JsonRpcCallback,
11-
ScClient,
9+
type Chain,
10+
type JsonRpcCallback,
11+
type ScClient,
1212
} from "./types.js"
1313
import { WellKnownChain } from "../WellKnownChain.js"
1414
import { getSpec } from "./specs/index.js"
@@ -28,7 +28,7 @@ function getRandomChainId(): string {
2828
const arr = new BigUint64Array(2)
2929
// It can only be used from the browser, so this is fine.
3030
crypto.getRandomValues(arr)
31-
const result = (arr[1] << BigInt(64)) | arr[0]
31+
const result = (arr[1]! << BigInt(64)) | arr[0]!
3232
return result.toString(36)
3333
}
3434

packages/connect/src/connector/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import {
22
createScClient as smoldotScClient,
3-
Config as EmbeddedNodeConfig,
3+
type Config as EmbeddedNodeConfig,
44
} from "./smoldot-light.js"
55
import { createScClient as extensionScClient } from "./extension.js"
66
import { DOM_ELEMENT_ID } from "@substrate/connect-extension-protocol"
77

88
export * from "./types.js"
9-
export { EmbeddedNodeConfig }
9+
export type { EmbeddedNodeConfig }
1010

1111
/**
1212
* `true` if the substrate-connect extension is installed and available.

packages/connect/src/connector/smoldot-light.test.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,23 +181,25 @@ describe("SmoldotConnect::smoldot", () => {
181181
const { addChain, addWellKnownChain } = smoldot.createScClient()
182182
const chainSpec = "testChainSpec"
183183
await addChain(chainSpec)
184-
let mockedChain = mockedSmoldotLight.getLatestClient()._getLatestChain()
184+
let mockedChain = mockedSmoldotLight
185+
.getLatestClient()
186+
._getLatestChain()!
185187
expect(mockedChain._addChainOptions.chainSpec).toEqual(chainSpec)
186188

187189
await addWellKnownChain(WellKnownChain.polkadot)
188-
mockedChain = mockedSmoldotLight.getLatestClient()._getLatestChain()
190+
mockedChain = mockedSmoldotLight.getLatestClient()._getLatestChain()!
189191
expect(mockedChain._addChainOptions.chainSpec).toEqual(
190192
"fake-polkadot-spec",
191193
)
192194

193195
await addWellKnownChain(WellKnownChain.ksmcc3)
194-
mockedChain = mockedSmoldotLight.getLatestClient()._getLatestChain()
196+
mockedChain = mockedSmoldotLight.getLatestClient()._getLatestChain()!
195197
expect(mockedChain._addChainOptions.chainSpec).toEqual(
196198
"fake-ksmcc3-spec",
197199
)
198200

199201
await addWellKnownChain(WellKnownChain.rococo_v2_2)
200-
mockedChain = mockedSmoldotLight.getLatestClient()._getLatestChain()
202+
mockedChain = mockedSmoldotLight.getLatestClient()._getLatestChain()!
201203
expect(mockedChain._addChainOptions.chainSpec).toEqual(
202204
"fake-rococo_v2_2-spec",
203205
)
@@ -212,14 +214,14 @@ describe("SmoldotConnect::smoldot", () => {
212214
.fill(null)
213215
.map(() => addChain("")),
214216
)
215-
prevChains[0].remove()
217+
prevChains[0]!.remove()
216218
await addChain("")
217219
const mockedChains = mockedSmoldotLight
218220
.getLatestClient()
219221
._getChains()
220222
.slice(-4)
221223
const lastMockedChain = mockedChains[3]
222-
expect(lastMockedChain._addChainOptions.potentialRelayChains).toEqual([
224+
expect(lastMockedChain!._addChainOptions.potentialRelayChains).toEqual([
223225
mockedChains[1],
224226
mockedChains[2],
225227
])

packages/connect/src/connector/smoldot-light.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
import { Chain as SChain, Client, ClientOptions, QueueFullError } from "smoldot"
1+
import {
2+
type Chain as SChain,
3+
type Client,
4+
type ClientOptions,
5+
QueueFullError,
6+
} from "smoldot"
27
import { getSpec } from "./specs/index.js"
38
import {
4-
AddChain,
5-
AddWellKnownChain,
6-
Chain,
7-
ScClient,
9+
type AddChain,
10+
type AddWellKnownChain,
11+
type Chain,
12+
type ScClient,
813
AlreadyDestroyedError,
914
CrashError,
1015
JsonRpcDisabledError,

0 commit comments

Comments
 (0)