Skip to content

Commit

Permalink
fix(typecheck): use unique temp and tsbuildinfo file for each tsconfi…
Browse files Browse the repository at this point in the history
…g file (fix #7107) (#7112)
  • Loading branch information
masnormen authored Dec 23, 2024
1 parent 579bda9 commit 61b3016
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions packages/vitest/src/typecheck/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,13 @@ export async function getTsconfig(root: string, config: TypecheckConfig) {
throw new Error('no tsconfig.json found')
}

const tsconfigName = basename(tsconfig.path, '.json')
const tempTsConfigName = `${tsconfigName}.vitest-temp.json`
const tempTsbuildinfoName = `${tsconfigName}.tmp.tsbuildinfo`

const tempConfigPath = join(
dirname(tsconfig.path),
'tsconfig.vitest-temp.json',
tempTsConfigName,
)

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

const tsconfigFinalContent = JSON.stringify(tmpTsConfig, null, 2)
await writeFile(tempConfigPath, tsconfigFinalContent)
return { path: tempConfigPath, config: tmpTsConfig }
}
catch (err) {
throw new Error('failed to write tsconfig.temp.json', { cause: err })
throw new Error(`failed to write ${tempTsConfigName}`, { cause: err })
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/typescript/test/__snapshots__/runner.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.
⎯⎯⎯⎯⎯⎯ Typecheck Error ⎯⎯⎯⎯⎯⎯⎯
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/**"]'.
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/**"]'.
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Expand Down

0 comments on commit 61b3016

Please sign in to comment.