Skip to content

Commit b871d8b

Browse files
authored
Merge pull request #5206 from aryaemami59/chore/toolkit/migrate-to-bundler
chore(toolkit): migrate TypeScript setup to `"moduleResolution": "bundler"`
2 parents eb36871 + 3b606d6 commit b871d8b

4 files changed

Lines changed: 32 additions & 42 deletions

File tree

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,39 @@
11
{
22
"compilerOptions": {
3-
"target": "ESnext",
4-
"module": "ESnext",
5-
"lib": ["DOM", "ESNext"],
6-
"importHelpers": true,
7-
// output .d.ts declaration files for consumers
3+
"allowSyntheticDefaultImports": true,
84
"declaration": true,
9-
// match output dir to input dir. e.g. dist/index instead of dist/src/index
10-
"rootDir": "./src",
11-
// stricter type-checking for stronger correctness. Recommended by TS
12-
"strict": true,
13-
// linter checks for common issues
14-
"noImplicitReturns": true,
15-
"noFallthroughCasesInSwitch": true,
16-
// noUnused* overlap with @typescript-eslint/no-unused-vars, can disable if duplicative
17-
"noUnusedLocals": false,
18-
"noUnusedParameters": false,
19-
// use Node's module resolution algorithm, instead of the legacy TS one
20-
"moduleResolution": "Node",
21-
// transpile JSX to React.createElement
22-
"jsx": "react",
23-
// interop between ESM and CJS modules. Recommended by TS
5+
"declarationMap": true,
246
"esModuleInterop": true,
25-
// significant perf increase by skipping checking .d.ts files, particularly those in node_modules. Recommended by TS
26-
"skipLibCheck": true,
27-
// error out if import and file system have a casing mismatch. Recommended by TS
287
"forceConsistentCasingInFileNames": true,
29-
// ensure that each file can be safely transpiled by babel (etc.) without relying on other imports
308
"isolatedModules": true,
31-
"downlevelIteration": false,
32-
"allowSyntheticDefaultImports": true,
33-
"emitDeclarationOnly": true,
34-
"types": ["vitest/globals", "vitest/importMeta", "node"],
9+
"jsx": "react",
10+
"lib": ["DOM", "ESNext"],
11+
"module": "esnext",
12+
"moduleDetection": "force",
13+
"moduleResolution": "bundler",
14+
"noEmit": true,
15+
"noEmitOnError": true,
16+
"noErrorTruncation": true,
17+
"noFallthroughCasesInSwitch": true,
18+
"noImplicitOverride": true,
19+
"noImplicitReturns": true,
20+
"outDir": "./dist",
3521
"paths": {
22+
// internal imports in tests only
23+
"@internal/*": ["./src/*"],
3624
"@reduxjs/toolkit": ["./src/index.ts"], // @remap-prod-remove-line
37-
"@reduxjs/toolkit/react": ["./src/react/index.ts"], // @remap-prod-remove-line
3825
"@reduxjs/toolkit/query": ["./src/query/index.ts"], // @remap-prod-remove-line
3926
"@reduxjs/toolkit/query/react": ["./src/query/react/index.ts"], // @remap-prod-remove-line
40-
// internal imports in tests only
41-
"@internal/*": ["./src/*"]
42-
}
27+
"@reduxjs/toolkit/react": ["./src/react/index.ts"] // @remap-prod-remove-line
28+
},
29+
"resolveJsonModule": true,
30+
"rootDir": "./src",
31+
"skipLibCheck": true,
32+
"sourceMap": true,
33+
"strict": true,
34+
"target": "esnext",
35+
"types": ["node", "vitest/globals", "vitest/importMeta"],
36+
"useDefineForClassFields": true,
37+
"useUnknownInCatchVariables": true
4338
}
4439
}

packages/toolkit/tsconfig.build.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// For building the library.
33
"extends": "./tsconfig.base.json",
44
"compilerOptions": {
5-
"outDir": "dist"
5+
"noEmit": false
66
},
77
"include": ["src"],
88
"exclude": [

packages/toolkit/tsconfig.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// we are using during development.
55
"extends": "./tsconfig.test.json",
66
"compilerOptions": {
7-
"skipLibCheck": true,
8-
"rootDir": "."
7+
"rootDir": "./"
98
},
10-
"include": ["."]
9+
"include": ["."],
10+
"exclude": ["dist", "scripts/issue-triage"]
1111
}

packages/toolkit/tsconfig.test.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22
// For runtime and type tests during CI.
33
"extends": "./tsconfig.base.json",
44
"compilerOptions": {
5-
"emitDeclarationOnly": false,
6-
"noEmit": true,
7-
"rootDir": "./src",
8-
"jsx": "react-jsx",
9-
"skipLibCheck": true,
10-
"noImplicitReturns": false
5+
"jsx": "react-jsx"
116
},
127
"exclude": ["dist"],
138
"include": [

0 commit comments

Comments
 (0)