Skip to content

Commit

Permalink
Disallow incremental with noEmit (#36483)
Browse files Browse the repository at this point in the history
Fixes #32882
  • Loading branch information
sheetalkamat authored Jan 28, 2020
1 parent f91f762 commit 0e9416c
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2987,6 +2987,10 @@ namespace ts {
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified));
}

if (options.noEmit && isIncrementalCompilation(options)) {
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", options.incremental ? "incremental" : "composite");
}

verifyProjectReferences();

// List of collected files is complete; validate exhautiveness if this is a project with a file list
Expand Down
19 changes: 19 additions & 0 deletions tests/baselines/reference/noEmitAndComposite.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/tsconfig.json(3,9): error TS5053: Option 'noEmit' cannot be specified with option 'composite'.
/tsconfig.json(4,9): error TS5053: Option 'noEmit' cannot be specified with option 'composite'.


==== /tsconfig.json (2 errors) ====
{
"compilerOptions": {
"noEmit": true,
~~~~~~~~
!!! error TS5053: Option 'noEmit' cannot be specified with option 'composite'.
"composite": true
~~~~~~~~~~~
!!! error TS5053: Option 'noEmit' cannot be specified with option 'composite'.
}
}

==== /a.ts (0 errors) ====
const x = 10;

4 changes: 4 additions & 0 deletions tests/baselines/reference/noEmitAndComposite.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
=== /a.ts ===
const x = 10;
>x : Symbol(x, Decl(a.ts, 0, 5))

5 changes: 5 additions & 0 deletions tests/baselines/reference/noEmitAndComposite.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
=== /a.ts ===
const x = 10;
>x : 10
>10 : 10

20 changes: 20 additions & 0 deletions tests/baselines/reference/noEmitAndIncremental.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/tsconfig.json(3,9): error TS5053: Option 'noEmit' cannot be specified with option 'incremental'.
/tsconfig.json(4,9): error TS5053: Option 'noEmit' cannot be specified with option 'incremental'.


==== /tsconfig.json (2 errors) ====
{
"compilerOptions": {
"noEmit": true,
~~~~~~~~
!!! error TS5053: Option 'noEmit' cannot be specified with option 'incremental'.
"incremental": true
~~~~~~~~~~~~~
!!! error TS5053: Option 'noEmit' cannot be specified with option 'incremental'.
}
}


==== /a.ts (0 errors) ====
const x = 10;

4 changes: 4 additions & 0 deletions tests/baselines/reference/noEmitAndIncremental.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
=== /a.ts ===
const x = 10;
>x : Symbol(x, Decl(a.ts, 0, 5))

5 changes: 5 additions & 0 deletions tests/baselines/reference/noEmitAndIncremental.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
=== /a.ts ===
const x = 10;
>x : 10
>10 : 10

10 changes: 10 additions & 0 deletions tests/cases/compiler/noEmitAndComposite.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// @Filename: /a.ts
const x = 10;

// @Filename: /tsconfig.json
{
"compilerOptions": {
"noEmit": true,
"composite": true
}
}
11 changes: 11 additions & 0 deletions tests/cases/compiler/noEmitAndIncremental.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// @Filename: /a.ts
const x = 10;

// @Filename: /tsconfig.json
{
"compilerOptions": {
"noEmit": true,
"incremental": true
}
}

0 comments on commit 0e9416c

Please sign in to comment.