Skip to content

Commit 61b3016

Browse files
authored
fix(typecheck): use unique temp and tsbuildinfo file for each tsconfig file (fix #7107) (#7112)
1 parent 579bda9 commit 61b3016

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

packages/vitest/src/typecheck/parse.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,13 @@ export async function getTsconfig(root: string, config: TypecheckConfig) {
7575
throw new Error('no tsconfig.json found')
7676
}
7777

78+
const tsconfigName = basename(tsconfig.path, '.json')
79+
const tempTsConfigName = `${tsconfigName}.vitest-temp.json`
80+
const tempTsbuildinfoName = `${tsconfigName}.tmp.tsbuildinfo`
81+
7882
const tempConfigPath = join(
7983
dirname(tsconfig.path),
80-
'tsconfig.vitest-temp.json',
84+
tempTsConfigName,
8185
)
8286

8387
try {
@@ -88,15 +92,15 @@ export async function getTsconfig(root: string, config: TypecheckConfig) {
8892
tmpTsConfig.compilerOptions.incremental = true
8993
tmpTsConfig.compilerOptions.tsBuildInfoFile = join(
9094
process.versions.pnp ? join(os.tmpdir(), 'vitest') : __dirname,
91-
'tsconfig.tmp.tsbuildinfo',
95+
tempTsbuildinfoName,
9296
)
9397

9498
const tsconfigFinalContent = JSON.stringify(tmpTsConfig, null, 2)
9599
await writeFile(tempConfigPath, tsconfigFinalContent)
96100
return { path: tempConfigPath, config: tmpTsConfig }
97101
}
98102
catch (err) {
99-
throw new Error('failed to write tsconfig.temp.json', { cause: err })
103+
throw new Error(`failed to write ${tempTsConfigName}`, { cause: err })
100104
}
101105
}
102106

test/typescript/test/__snapshots__/runner.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Vitest caught 1 unhandled error during the test run.
9696
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.
9797
9898
⎯⎯⎯⎯⎯⎯ Typecheck Error ⎯⎯⎯⎯⎯⎯⎯
99-
Error: error TS18003: No inputs were found in config file '<root>/tsconfig.vitest-temp.json'. Specified 'include' paths were '["src"]' and 'exclude' paths were '["**/dist/**"]'.
99+
Error: error TS18003: No inputs were found in config file '<root>/tsconfig.empty.vitest-temp.json'. Specified 'include' paths were '["src"]' and 'exclude' paths were '["**/dist/**"]'.
100100
101101
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
102102

0 commit comments

Comments
 (0)