Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/guide/cli-generated.md
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,13 @@ Allow JavaScript files to be typechecked. By default takes the value from tsconf

Ignore type errors from source files

### typecheck.build

- **CLI:** `--typecheck.build`
- **Config:** [typecheck.build](/config/typecheck#typecheck-build)

Use TypeScript build mode

### typecheck.tsconfig

- **CLI:** `--typecheck.tsconfig <path>`
Expand Down
3 changes: 3 additions & 0 deletions packages/vitest/src/node/cli/cli-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,9 @@ export const cliOptionsConfig: VitestCLIOptions = {
ignoreSourceErrors: {
description: 'Ignore type errors from source files',
},
build: {
description: 'Use TypeScript build mode',
},
tsconfig: {
description: 'Path to a custom tsconfig file',
argument: '<path>',
Expand Down
4 changes: 4 additions & 0 deletions packages/vitest/src/node/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,10 @@ export interface TypecheckConfig {
* Do not fail, if Vitest found errors outside the test files.
*/
ignoreSourceErrors?: boolean
/**
* Use TypeScript build mode.
*/
build?: boolean
/**
* Path to tsconfig, relative to the project root.
*/
Expand Down
29 changes: 21 additions & 8 deletions packages/vitest/src/typecheck/typechecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,16 +294,25 @@ export class Typechecker {
const { root, watch, typecheck } = this.project.config

const args = [
'--noEmit',
'--pretty',
'false',
'--incremental',
'--tsBuildInfoFile',
join(
process.versions.pnp ? join(os.tmpdir(), this.project.hash) : distDir,
'tsconfig.tmp.tsbuildinfo',
),
]

if (typecheck.build) {
args.push('--build')
}
else {
args.push(
'--noEmit',
'--incremental',
'--tsBuildInfoFile',
join(
process.versions.pnp ? join(os.tmpdir(), this.project.hash) : distDir,
'tsconfig.tmp.tsbuildinfo',
),
)
}

// use builtin watcher because it's faster
if (watch) {
args.push('--watch')
Expand All @@ -312,7 +321,11 @@ export class Typechecker {
args.push('--allowJs', '--checkJs')
}
if (typecheck.tsconfig) {
args.push('-p', resolve(root, typecheck.tsconfig))
if (!typecheck.build) {
args.push('-p')
}

args.push(resolve(root, typecheck.tsconfig))
}
this._output = ''
this._startTime = performance.now()
Expand Down
Loading