diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 5fd178a891f..f524a549859 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1685,6 +1685,10 @@ namespace ts { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", "declaration")); } + if (options.checkJs && !options.allowJs) { + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); + } + if (options.emitDecoratorMetadata && !options.experimentalDecorators) { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); diff --git a/tests/baselines/reference/checkJsFiles6.errors.txt b/tests/baselines/reference/checkJsFiles6.errors.txt new file mode 100644 index 00000000000..89063e50698 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles6.errors.txt @@ -0,0 +1,9 @@ +error TS5052: Option 'checkJs' cannot be specified without specifying option 'allowJs'. +error TS6054: File 'tests/cases/compiler/a.js' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. + + +!!! error TS5052: Option 'checkJs' cannot be specified without specifying option 'allowJs'. +!!! error TS6054: File 'tests/cases/compiler/a.js' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. +==== tests/cases/compiler/a.js (0 errors) ==== + + var x; \ No newline at end of file diff --git a/tests/cases/compiler/checkJsFiles6.ts b/tests/cases/compiler/checkJsFiles6.ts new file mode 100644 index 00000000000..358704ae22e --- /dev/null +++ b/tests/cases/compiler/checkJsFiles6.ts @@ -0,0 +1,6 @@ +// @allowJs: false +// @checkJs: true +// @noEmit: true + +// @fileName: a.js +var x; \ No newline at end of file