-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(type-check): allow to check multiple tsconfig files (#2684)
- Loading branch information
1 parent
c260257
commit b10c2b7
Showing
8 changed files
with
99 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { build } from '@e2e/helper'; | ||
import { proxyConsole } from '@e2e/helper'; | ||
import { expect, test } from '@playwright/test'; | ||
|
||
test('should check multiple tsconfig.json as expected', async () => { | ||
const { logs, restore } = proxyConsole(); | ||
await expect( | ||
build({ | ||
cwd: __dirname, | ||
}), | ||
).rejects.toThrowError('build failed!'); | ||
|
||
expect( | ||
logs.find((log) => | ||
log.includes( | ||
`Argument of type 'string' is not assignable to parameter of type 'number'.`, | ||
), | ||
), | ||
).toBeTruthy(); | ||
|
||
expect( | ||
logs.find((log) => | ||
log.includes( | ||
`Argument of type '{}' is not assignable to parameter of type 'number'.`, | ||
), | ||
), | ||
).toBeTruthy(); | ||
|
||
restore(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { defineConfig } from '@rsbuild/core'; | ||
import { pluginTypeCheck } from '@rsbuild/plugin-type-check'; | ||
|
||
export default defineConfig({ | ||
plugins: [pluginTypeCheck()], | ||
environments: { | ||
web: { | ||
output: { | ||
target: 'web', | ||
}, | ||
}, | ||
node: { | ||
source: { | ||
tsconfigPath: './tsconfig.server.json', | ||
}, | ||
output: { | ||
target: 'node', | ||
}, | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const add = (a: number, b: number) => a + b; | ||
|
||
// this is a type error | ||
add(1, '2'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const add = (a: number, b: number) => a + b; | ||
|
||
// this is a type error | ||
add(1, {}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "@rsbuild/config/tsconfig", | ||
"compilerOptions": { | ||
"jsx": "react-jsx", | ||
"baseUrl": "./", | ||
"outDir": "./dist", | ||
"paths": { | ||
"@/*": ["./src/*"] | ||
} | ||
}, | ||
"include": ["src"] | ||
} |
12 changes: 12 additions & 0 deletions
12
e2e/cases/type-check/multiple-tsconfig/tsconfig.server.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "@rsbuild/config/tsconfig", | ||
"compilerOptions": { | ||
"jsx": "react-jsx", | ||
"baseUrl": "./", | ||
"outDir": "./dist", | ||
"paths": { | ||
"@/*": ["./src/*"] | ||
} | ||
}, | ||
"include": ["server"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters