Skip to content

Commit 39b38c8

Browse files
arbrandesclaude
andcommitted
fix: exclude test files from webpack TypeScript checking
Exclude src/**/*.test.* and src/**/*.spec.* from tsconfig.json so the webpack dev server's ForkTsCheckerWebpackPlugin doesn't type-check them (they use jest globals not available in the webpack context). Add tsconfig.lint.json (extends tsconfig.json, re-includes test files) and point eslint at it so type-aware linting still covers tests. Cast environment in site.config.test.tsx to satisfy the type checker without importing EnvironmentTypes (which causes a circular dependency). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 89f7fcb commit 39b38c8

4 files changed

Lines changed: 28 additions & 1 deletion

File tree

eslint.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,15 @@ module.exports = createLintConfig(
1919
'**/__snapshots__/*',
2020
],
2121
},
22+
{
23+
// Test files are excluded from tsconfig.json to prevent the webpack dev server's
24+
// ForkTsCheckerWebpackPlugin from type-checking them. Use a separate tsconfig for
25+
// eslint that re-includes test files for type-aware linting.
26+
languageOptions: {
27+
parserOptions: {
28+
projectService: false,
29+
project: './tsconfig.lint.json',
30+
},
31+
},
32+
},
2233
);

site.config.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const siteConfig: SiteConfig = {
1212

1313
// Use 'test' instead of EnvironmentTypes.TEST to break a circular dependency:
1414
// initialize.js imports site.config → site.config imports @openedx/frontend-base → still loading
15-
environment: 'test',
15+
environment: 'test' as SiteConfig['environment'],
1616
basename: '/learner-dashboard',
1717
apps: [{
1818
appId,

tsconfig.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,9 @@
1515
"eslint.config.js",
1616
"jest.config.js",
1717
"site.config.*.tsx"
18+
],
19+
"exclude": [
20+
"src/**/*.test.*",
21+
"src/**/*.spec.*"
1822
]
1923
}

tsconfig.lint.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"include": [
4+
"src/**/*",
5+
"app.d.ts",
6+
"babel.config.js",
7+
"eslint.config.js",
8+
"jest.config.js",
9+
"site.config.*.tsx"
10+
],
11+
"exclude": []
12+
}

0 commit comments

Comments
 (0)