Skip to content

Commit 71e25cd

Browse files
authored
Merge pull request #16210 from amcasey/Vso411288
Apply --checkjs to bind diagnostics as well as check diagnostics
2 parents 856c0fd + 549485d commit 71e25cd

15 files changed

+91
-6
lines changed

src/compiler/program.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,10 +1069,10 @@ namespace ts {
10691069
const typeChecker = getDiagnosticsProducingTypeChecker();
10701070

10711071
Debug.assert(!!sourceFile.bindDiagnostics);
1072-
const bindDiagnostics = sourceFile.bindDiagnostics;
10731072
// For JavaScript files, we don't want to report semantic errors unless explicitly requested.
1074-
const includeCheckDiagnostics = !isSourceFileJavaScript(sourceFile) || isCheckJsEnabledForFile(sourceFile, options);
1075-
const checkDiagnostics = includeCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : [];
1073+
const includeBindAndCheckDiagnostics = !isSourceFileJavaScript(sourceFile) || isCheckJsEnabledForFile(sourceFile, options);
1074+
const bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : emptyArray;
1075+
const checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : emptyArray;
10761076
const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
10771077
const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
10781078

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
tests/cases/compiler/a.js(1,22): error TS2528: A module cannot have multiple default exports.
2+
tests/cases/compiler/a.js(1,22): error TS2652: Merged declaration 'a' cannot include a default export declaration. Consider adding a separate 'export default a' declaration instead.
23
tests/cases/compiler/a.js(3,1): error TS2528: A module cannot have multiple default exports.
34
tests/cases/compiler/a.js(3,16): error TS1109: Expression expected.
5+
tests/cases/compiler/a.js(3,20): error TS2652: Merged declaration 'a' cannot include a default export declaration. Consider adding a separate 'export default a' declaration instead.
46

57

6-
==== tests/cases/compiler/a.js (3 errors) ====
8+
==== tests/cases/compiler/a.js (5 errors) ====
79
export default class a {
810
~
911
!!! error TS2528: A module cannot have multiple default exports.
12+
~
13+
!!! error TS2652: Merged declaration 'a' cannot include a default export declaration. Consider adding a separate 'export default a' declaration instead.
1014
}
1115
export default var a = 10;
1216
~~~~~~~~~~~~~~
1317
!!! error TS2528: A module cannot have multiple default exports.
1418
~~~
15-
!!! error TS1109: Expression expected.
19+
!!! error TS1109: Expression expected.
20+
~
21+
!!! error TS2652: Merged declaration 'a' cannot include a default export declaration. Consider adding a separate 'export default a' declaration instead.

tests/baselines/reference/jsFileCompilationBindStrictModeErrors.errors.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
tests/cases/compiler/a.js(5,5): error TS1117: An object literal cannot have multiple properties with the same name in strict mode.
2+
tests/cases/compiler/a.js(5,5): error TS2300: Duplicate identifier 'a'.
23
tests/cases/compiler/a.js(7,5): error TS1212: Identifier expected. 'let' is a reserved word in strict mode.
34
tests/cases/compiler/a.js(8,8): error TS1102: 'delete' cannot be called on an identifier in strict mode.
5+
tests/cases/compiler/a.js(8,8): error TS2703: The operand of a delete operator must be a property reference.
46
tests/cases/compiler/a.js(10,10): error TS1100: Invalid use of 'eval' in strict mode.
57
tests/cases/compiler/a.js(12,10): error TS1100: Invalid use of 'arguments' in strict mode.
68
tests/cases/compiler/a.js(15,1): error TS1101: 'with' statements are not allowed in strict mode.
9+
tests/cases/compiler/a.js(15,1): error TS2410: The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'.
710
tests/cases/compiler/b.js(3,7): error TS1210: Invalid use of 'eval'. Class definitions are automatically in strict mode.
811
tests/cases/compiler/b.js(6,13): error TS1213: Identifier expected. 'let' is a reserved word in strict mode. Class definitions are automatically in strict mode.
912
tests/cases/compiler/c.js(1,12): error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode.
@@ -12,21 +15,25 @@ tests/cases/compiler/d.js(2,9): error TS1121: Octal literals are not allowed in
1215
tests/cases/compiler/d.js(2,11): error TS1005: ',' expected.
1316

1417

15-
==== tests/cases/compiler/a.js (6 errors) ====
18+
==== tests/cases/compiler/a.js (9 errors) ====
1619
"use strict";
1720
var a = {
1821
a: "hello", // error
1922
b: 10,
2023
a: 10 // error
2124
~
2225
!!! error TS1117: An object literal cannot have multiple properties with the same name in strict mode.
26+
~
27+
!!! error TS2300: Duplicate identifier 'a'.
2328
};
2429
var let = 10; // error
2530
~~~
2631
!!! error TS1212: Identifier expected. 'let' is a reserved word in strict mode.
2732
delete a; // error
2833
~
2934
!!! error TS1102: 'delete' cannot be called on an identifier in strict mode.
35+
~
36+
!!! error TS2703: The operand of a delete operator must be a property reference.
3037
try {
3138
} catch (eval) { // error
3239
~~~~
@@ -40,6 +47,8 @@ tests/cases/compiler/d.js(2,11): error TS1005: ',' expected.
4047
with (a) {
4148
~~~~
4249
!!! error TS1101: 'with' statements are not allowed in strict mode.
50+
~~~~~~~~
51+
!!! error TS2410: The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'.
4352
b = 10;
4453
}
4554

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
tests/cases/compiler/unreachable.js(3,5): error TS7027: Unreachable code detected.
2+
3+
4+
==== tests/cases/compiler/unreachable.js (1 errors) ====
5+
function unreachable() {
6+
return 1;
7+
return 2;
8+
~~~~~~
9+
!!! error TS7027: Unreachable code detected.
10+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//// [unreachable.js]
2+
function unreachable() {
3+
return 1;
4+
return 2;
5+
}
6+
7+
//// [unreachable.js]
8+
function unreachable() {
9+
return 1;
10+
return 2;
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//// [unreachable.js]
2+
function unreachable() {
3+
return 1;
4+
return 2;
5+
}
6+
7+
//// [unreachable.js]
8+
function unreachable() {
9+
return 1;
10+
return 2;
11+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
=== tests/cases/compiler/unreachable.js ===
2+
function unreachable() {
3+
>unreachable : Symbol(unreachable, Decl(unreachable.js, 0, 0))
4+
5+
return 1;
6+
return 2;
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
=== tests/cases/compiler/unreachable.js ===
2+
function unreachable() {
3+
>unreachable : () => 1 | 2
4+
5+
return 1;
6+
>1 : 1
7+
8+
return 2;
9+
>2 : 2
10+
}

tests/cases/compiler/jsFileCompilationBindDuplicateIdentifier.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// @allowJs: true
2+
// @checkJs: true
23
// @noEmit: true
34
// @filename: a.js
45
var a = 10;

tests/cases/compiler/jsFileCompilationBindErrors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// @allowJs: true
2+
// @checkJs: true
23
// @noEmit: true
34
// @filename: a.js
45
let C = "sss";

0 commit comments

Comments
 (0)