File tree Expand file tree Collapse file tree
Open diff view settings
Expand file tree Collapse file tree
Open diff view settings
Original file line number Diff line number Diff line change @@ -6322,6 +6322,12 @@ namespace ts {
63226322 comment . parent = parent ;
63236323 }
63246324
6325+ if ( isInJavaScriptFile ( parent ) ) {
6326+ if ( ! sourceFile . jsDocDiagnostics ) {
6327+ sourceFile . jsDocDiagnostics = [ ] ;
6328+ }
6329+ sourceFile . jsDocDiagnostics . push ( ...parseDiagnostics ) ;
6330+ }
63256331 currentToken = saveToken ;
63266332 parseDiagnostics . length = saveParseDiagnosticsLength ;
63276333 parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode ;
Original file line number Diff line number Diff line change @@ -1021,6 +1021,9 @@ namespace ts {
10211021 if ( isSourceFileJavaScript ( sourceFile ) ) {
10221022 if ( ! sourceFile . additionalSyntacticDiagnostics ) {
10231023 sourceFile . additionalSyntacticDiagnostics = getJavaScriptSyntacticDiagnosticsForFile ( sourceFile ) ;
1024+ if ( isCheckJsEnabledForFile ( sourceFile , options ) ) {
1025+ sourceFile . additionalSyntacticDiagnostics = concatenate ( sourceFile . additionalSyntacticDiagnostics , sourceFile . jsDocDiagnostics ) ;
1026+ }
10241027 }
10251028 return concatenate ( sourceFile . additionalSyntacticDiagnostics , sourceFile . parseDiagnostics ) ;
10261029 }
Original file line number Diff line number Diff line change @@ -2316,16 +2316,19 @@ namespace ts {
23162316 /* @internal */ identifierCount : number ;
23172317 /* @internal */ symbolCount : number ;
23182318
2319- // File level diagnostics reported by the parser (includes diagnostics about /// references
2319+ // File- level diagnostics reported by the parser (includes diagnostics about /// references
23202320 // as well as code diagnostics).
23212321 /* @internal */ parseDiagnostics : Diagnostic [ ] ;
23222322
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.
23272324 /* @internal */ bindDiagnostics : Diagnostic [ ] ;
23282325
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+
23292332 // Stores a line map for the file.
23302333 // This field should never be used directly to obtain line map, use getLineMap function instead.
23312334 /* @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