diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 12dbe71f590..1c7cb0ca2c4 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2850,6 +2850,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 diff --git a/tests/baselines/reference/noEmitAndComposite.errors.txt b/tests/baselines/reference/noEmitAndComposite.errors.txt new file mode 100644 index 00000000000..fe6de6ae441 --- /dev/null +++ b/tests/baselines/reference/noEmitAndComposite.errors.txt @@ -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; + \ No newline at end of file diff --git a/tests/baselines/reference/noEmitAndComposite.symbols b/tests/baselines/reference/noEmitAndComposite.symbols new file mode 100644 index 00000000000..05c35bcf58a --- /dev/null +++ b/tests/baselines/reference/noEmitAndComposite.symbols @@ -0,0 +1,4 @@ +=== /a.ts === +const x = 10; +>x : Symbol(x, Decl(a.ts, 0, 5)) + diff --git a/tests/baselines/reference/noEmitAndComposite.types b/tests/baselines/reference/noEmitAndComposite.types new file mode 100644 index 00000000000..ed892fed2ba --- /dev/null +++ b/tests/baselines/reference/noEmitAndComposite.types @@ -0,0 +1,5 @@ +=== /a.ts === +const x = 10; +>x : 10 +>10 : 10 + diff --git a/tests/baselines/reference/noEmitAndIncremental.errors.txt b/tests/baselines/reference/noEmitAndIncremental.errors.txt new file mode 100644 index 00000000000..c257e9ba540 --- /dev/null +++ b/tests/baselines/reference/noEmitAndIncremental.errors.txt @@ -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; + \ No newline at end of file diff --git a/tests/baselines/reference/noEmitAndIncremental.symbols b/tests/baselines/reference/noEmitAndIncremental.symbols new file mode 100644 index 00000000000..05c35bcf58a --- /dev/null +++ b/tests/baselines/reference/noEmitAndIncremental.symbols @@ -0,0 +1,4 @@ +=== /a.ts === +const x = 10; +>x : Symbol(x, Decl(a.ts, 0, 5)) + diff --git a/tests/baselines/reference/noEmitAndIncremental.types b/tests/baselines/reference/noEmitAndIncremental.types new file mode 100644 index 00000000000..ed892fed2ba --- /dev/null +++ b/tests/baselines/reference/noEmitAndIncremental.types @@ -0,0 +1,5 @@ +=== /a.ts === +const x = 10; +>x : 10 +>10 : 10 + diff --git a/tests/cases/compiler/noEmitAndComposite.ts b/tests/cases/compiler/noEmitAndComposite.ts new file mode 100644 index 00000000000..849fdb04da1 --- /dev/null +++ b/tests/cases/compiler/noEmitAndComposite.ts @@ -0,0 +1,10 @@ +// @Filename: /a.ts +const x = 10; + +// @Filename: /tsconfig.json +{ + "compilerOptions": { + "noEmit": true, + "composite": true + } +} diff --git a/tests/cases/compiler/noEmitAndIncremental.ts b/tests/cases/compiler/noEmitAndIncremental.ts new file mode 100644 index 00000000000..0349496c1ef --- /dev/null +++ b/tests/cases/compiler/noEmitAndIncremental.ts @@ -0,0 +1,11 @@ +// @Filename: /a.ts +const x = 10; + +// @Filename: /tsconfig.json +{ + "compilerOptions": { + "noEmit": true, + "incremental": true + } +} +