Skip to content

Commit 1d9d2d5

Browse files
authored
[Changed] Split tsconfig.json into composite project references for improve TypeScript UX (#197)
* refactor: Split `tsconfig.json` into composite project references for source and test configurations. * chore: Update tsconfig extends path from tsconfig.base.json to tsconfig.json in node and test configurations. * feat: Include `src` files in test TypeScript configuration. * feat: Include react types in node tsconfig. * refactor: move 'src/**/*' include directive from tsconfig.node.json to tsconfig.json * chore: Add `@ts-expect-error` comments to suppress type errors for global.fetch in test hooks. * feat: import Vitest globals and remove `@ts-expect-error` comments * Remove `vitest/globals` import and add `ts-expect-error` comments to test lifecycle hooks. * chore: remove redundant `src/**/*.tsx` from tsconfig include
1 parent bdf397d commit 1d9d2d5

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

src/wrap.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ import type {
1313
import { enhancedSpy } from './utils/tinyspyWrapper'
1414
import { MockInstance } from './utils/types'
1515

16+
// @ts-expect-error
1617
beforeEach(() => {
1718
// @ts-expect-error
1819
global.fetch = enhancedSpy()
1920
})
2021

22+
// @ts-expect-error
2123
afterEach(() => {
2224
// @ts-expect-error
2325
const mockedFetch = global.fetch as MockInstance

tsconfig.json

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,19 @@
1212
"skipLibCheck": true,
1313
"forceConsistentCasingInFileNames": true,
1414
"moduleResolution": "node",
15-
"types": [
16-
"vitest/globals",
17-
"react"
18-
],
1915
"esModuleInterop": true
2016
},
2117
"include": [
22-
"src/**/*"
18+
"src/**/*",
19+
"react",
20+
"vitest/globals"
2321
],
24-
"exclude": [
25-
"node_modules",
26-
"tests"
22+
"references": [
23+
{
24+
"path": "./tsconfig.node.json"
25+
},
26+
{
27+
"path": "./tsconfig.test.json"
28+
}
2729
]
28-
}
30+
}

tsconfig.node.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
},
5+
"extends": "./tsconfig.json",
6+
"exclude": [
7+
"tests/**/*"
8+
]
9+
}

tsconfig.test.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
},
5+
"extends": "./tsconfig.json",
6+
"include": [
7+
"tests/**/*",
8+
],
9+
}

0 commit comments

Comments
 (0)