Skip to content

Commit de38e40

Browse files
author
Paweł Aniszewski
committed
build(config): split tsconfig into IDE config and dedicated production compile
tsconfig.json now covers all src/ files (including __tests__ and __mocks__) so the VS Code language service resolves @types/jest and stops reporting errors in test files. tsconfig.build.json extends tsconfig.json and re-adds the test exclusions, keeping the production compile (tsc) free of test files. tsconfig.test.json extends tsconfig.json and adds jest/node types for ts-jest. jest.config.js wired to use it via globals["ts-jest"].tsconfig. package.json: compile and watch:types scripts now target tsconfig.build.json.
1 parent 503804b commit de38e40

5 files changed

Lines changed: 25 additions & 7 deletions

File tree

jest.config.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@ const tsJestTransformCfg = createDefaultPreset().transform;
44

55
/** @type {import("jest").Config} **/
66
module.exports = {
7-
testEnvironment: "node",
8-
transform: {
9-
...tsJestTransformCfg,
10-
},
7+
testEnvironment: "node",
8+
transform: {
9+
...tsJestTransformCfg,
10+
},
11+
globals: {
12+
"ts-jest": {
13+
tsconfig: "./tsconfig.test.json",
14+
},
15+
},
1116
};

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
"build:wasm": "scripts/pipeline.sh",
4444
"build:js": "npm run compile && npm run bundle && npm run build:worker && cp ./dist/assets/* ./assets/ && cp ./dist/bundle/rms-processor.js ./assets/",
4545
"build:worker": "webpack --config ./webpack.worker.config.js",
46-
"compile": "tsc",
46+
"compile": "tsc --project tsconfig.build.json",
4747
"bundle": "webpack",
48-
"watch:types": "tsc -w",
48+
"watch:types": "tsc -w --project tsconfig.build.json",
4949
"test:e2e": "playwright test --project=chromium",
5050
"test:e2e:manybrowsers": "playwright test",
5151
"lint": "eslint -c eslint.config.mjs .",

tsconfig.build.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"include": ["src"],
4+
"exclude": ["node_modules", "dist", "**/__tests__", "**/__mocks__"]
5+
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@
3030
"skipLibCheck": true
3131
},
3232
"include": ["src"],
33-
"exclude": ["node_modules", "dist", "**/__tests__", "**/__mocks__"]
33+
"exclude": ["node_modules", "dist"]
3434
}

tsconfig.test.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"types": ["jest", "node"]
5+
},
6+
"include": ["src"],
7+
"exclude": ["node_modules", "dist"]
8+
}

0 commit comments

Comments
 (0)