Skip to content

Commit 0e9416c

Browse files
authored
Disallow incremental with noEmit (#36483)
Fixes #32882
1 parent f91f762 commit 0e9416c

9 files changed

+82
-0
lines changed

src/compiler/program.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2987,6 +2987,10 @@ namespace ts {
29872987
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified));
29882988
}
29892989

2990+
if (options.noEmit && isIncrementalCompilation(options)) {
2991+
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", options.incremental ? "incremental" : "composite");
2992+
}
2993+
29902994
verifyProjectReferences();
29912995

29922996
// List of collected files is complete; validate exhautiveness if this is a project with a file list
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/tsconfig.json(3,9): error TS5053: Option 'noEmit' cannot be specified with option 'composite'.
2+
/tsconfig.json(4,9): error TS5053: Option 'noEmit' cannot be specified with option 'composite'.
3+
4+
5+
==== /tsconfig.json (2 errors) ====
6+
{
7+
"compilerOptions": {
8+
"noEmit": true,
9+
~~~~~~~~
10+
!!! error TS5053: Option 'noEmit' cannot be specified with option 'composite'.
11+
"composite": true
12+
~~~~~~~~~~~
13+
!!! error TS5053: Option 'noEmit' cannot be specified with option 'composite'.
14+
}
15+
}
16+
17+
==== /a.ts (0 errors) ====
18+
const x = 10;
19+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
=== /a.ts ===
2+
const x = 10;
3+
>x : Symbol(x, Decl(a.ts, 0, 5))
4+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
=== /a.ts ===
2+
const x = 10;
3+
>x : 10
4+
>10 : 10
5+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/tsconfig.json(3,9): error TS5053: Option 'noEmit' cannot be specified with option 'incremental'.
2+
/tsconfig.json(4,9): error TS5053: Option 'noEmit' cannot be specified with option 'incremental'.
3+
4+
5+
==== /tsconfig.json (2 errors) ====
6+
{
7+
"compilerOptions": {
8+
"noEmit": true,
9+
~~~~~~~~
10+
!!! error TS5053: Option 'noEmit' cannot be specified with option 'incremental'.
11+
"incremental": true
12+
~~~~~~~~~~~~~
13+
!!! error TS5053: Option 'noEmit' cannot be specified with option 'incremental'.
14+
}
15+
}
16+
17+
18+
==== /a.ts (0 errors) ====
19+
const x = 10;
20+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
=== /a.ts ===
2+
const x = 10;
3+
>x : Symbol(x, Decl(a.ts, 0, 5))
4+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
=== /a.ts ===
2+
const x = 10;
3+
>x : 10
4+
>10 : 10
5+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// @Filename: /a.ts
2+
const x = 10;
3+
4+
// @Filename: /tsconfig.json
5+
{
6+
"compilerOptions": {
7+
"noEmit": true,
8+
"composite": true
9+
}
10+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @Filename: /a.ts
2+
const x = 10;
3+
4+
// @Filename: /tsconfig.json
5+
{
6+
"compilerOptions": {
7+
"noEmit": true,
8+
"incremental": true
9+
}
10+
}
11+

0 commit comments

Comments
 (0)