Skip to content

Commit fb218b7

Browse files
committed
Error if --checkJs is used without --allowJs
1 parent 9305d4d commit fb218b7

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/compiler/program.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,10 @@ namespace ts {
16851685
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", "declaration"));
16861686
}
16871687

1688+
if (options.checkJs && !options.allowJs) {
1689+
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs"));
1690+
}
1691+
16881692
if (options.emitDecoratorMetadata &&
16891693
!options.experimentalDecorators) {
16901694
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators"));
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error TS5052: Option 'checkJs' cannot be specified without specifying option 'allowJs'.
2+
error TS6054: File 'tests/cases/compiler/a.js' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
3+
4+
5+
!!! error TS5052: Option 'checkJs' cannot be specified without specifying option 'allowJs'.
6+
!!! error TS6054: File 'tests/cases/compiler/a.js' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
7+
==== tests/cases/compiler/a.js (0 errors) ====
8+
9+
var x;

tests/cases/compiler/checkJsFiles6.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// @allowJs: false
2+
// @checkJs: true
3+
// @noEmit: true
4+
5+
// @fileName: a.js
6+
var x;

0 commit comments

Comments
 (0)