File tree Expand file tree Collapse file tree 5 files changed +68
-5
lines changed Expand file tree Collapse file tree 5 files changed +68
-5
lines changed Original file line number Diff line number Diff line change @@ -6322,6 +6322,12 @@ namespace ts {
6322
6322
comment . parent = parent ;
6323
6323
}
6324
6324
6325
+ if ( isInJavaScriptFile ( parent ) ) {
6326
+ if ( ! sourceFile . jsDocDiagnostics ) {
6327
+ sourceFile . jsDocDiagnostics = [ ] ;
6328
+ }
6329
+ sourceFile . jsDocDiagnostics . push ( ...parseDiagnostics ) ;
6330
+ }
6325
6331
currentToken = saveToken ;
6326
6332
parseDiagnostics . length = saveParseDiagnosticsLength ;
6327
6333
parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode ;
Original file line number Diff line number Diff line change @@ -1021,6 +1021,9 @@ namespace ts {
1021
1021
if ( isSourceFileJavaScript ( sourceFile ) ) {
1022
1022
if ( ! sourceFile . additionalSyntacticDiagnostics ) {
1023
1023
sourceFile . additionalSyntacticDiagnostics = getJavaScriptSyntacticDiagnosticsForFile ( sourceFile ) ;
1024
+ if ( isCheckJsEnabledForFile ( sourceFile , options ) ) {
1025
+ sourceFile . additionalSyntacticDiagnostics = concatenate ( sourceFile . additionalSyntacticDiagnostics , sourceFile . jsDocDiagnostics ) ;
1026
+ }
1024
1027
}
1025
1028
return concatenate ( sourceFile . additionalSyntacticDiagnostics , sourceFile . parseDiagnostics ) ;
1026
1029
}
Original file line number Diff line number Diff line change @@ -2316,16 +2316,19 @@ namespace ts {
2316
2316
/* @internal */ identifierCount : number ;
2317
2317
/* @internal */ symbolCount : number ;
2318
2318
2319
- // File level diagnostics reported by the parser (includes diagnostics about /// references
2319
+ // File- level diagnostics reported by the parser (includes diagnostics about /// references
2320
2320
// as well as code diagnostics).
2321
2321
/* @internal */ parseDiagnostics : Diagnostic [ ] ;
2322
2322
2323
- // Stores additional file level diagnostics reported by the program
2324
- /* @internal */ additionalSyntacticDiagnostics ?: Diagnostic [ ] ;
2325
-
2326
- // File level diagnostics reported by the binder.
2323
+ // File-level diagnostics reported by the binder.
2327
2324
/* @internal */ bindDiagnostics : Diagnostic [ ] ;
2328
2325
2326
+ // File-level JSDoc diagnostics reported by the JSDoc parser
2327
+ /* @internal */ jsDocDiagnostics ?: Diagnostic [ ] ;
2328
+
2329
+ // Stores additional file-level diagnostics reported by the program
2330
+ /* @internal */ additionalSyntacticDiagnostics ?: Diagnostic [ ] ;
2331
+
2329
2332
// Stores a line map for the file.
2330
2333
// This field should never be used directly to obtain line map, use getLineMap function instead.
2331
2334
/* @internal */ lineMap : number [ ] ;
Original file line number Diff line number Diff line change
1
+ tests/cases/conformance/jsdoc/foo.js(2,15): error TS1005: '}' expected.
2
+ tests/cases/conformance/jsdoc/foo.js(3,19): error TS1005: '}' expected.
3
+ tests/cases/conformance/jsdoc/foo.js(4,18): error TS1003: Identifier expected.
4
+ tests/cases/conformance/jsdoc/foo.js(4,19): error TS1005: '}' expected.
5
+
6
+
7
+ ==== tests/cases/conformance/jsdoc/foo.js (4 errors) ====
8
+ /**
9
+ * @param {(x)=>void} x
10
+ ~~
11
+ !!! error TS1005: '}' expected.
12
+ * @param {typeof String} y
13
+ ~~~~~~
14
+ !!! error TS1005: '}' expected.
15
+ * @param {string & number} z
16
+
17
+ !!! error TS1003: Identifier expected.
18
+ ~
19
+ !!! error TS1005: '}' expected.
20
+ **/
21
+ function foo(x, y, z) { }
22
+
23
+ ==== tests/cases/conformance/jsdoc/skipped.js (0 errors) ====
24
+ // @ts-nocheck
25
+ /**
26
+ * @param {(x)=>void} x
27
+ * @param {typeof String} y
28
+ * @param {string & number} z
29
+ **/
30
+ function bar(x, y, z) { }
31
+
Original file line number Diff line number Diff line change
1
+ // @checkJs : true
2
+ // @allowJs : true
3
+ // @noEmit : true
4
+
5
+ // @Filename : foo.js
6
+ /**
7
+ * @param {(x)=>void } x
8
+ * @param {typeof String } y
9
+ * @param {string & number } z
10
+ **/
11
+ function foo ( x , y , z ) { }
12
+
13
+ // @Filename : skipped.js
14
+ // @ts -nocheck
15
+ /**
16
+ * @param {(x)=>void } x
17
+ * @param {typeof String } y
18
+ * @param {string & number } z
19
+ **/
20
+ function bar ( x , y , z ) { }
You can’t perform that action at this time.
0 commit comments