Skip to content

Commit 2dd6627

Browse files
committed
Report jsdoc syntax errors when checkJs is on
1 parent f938caf commit 2dd6627

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/compiler/parser.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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;

src/compiler/program.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

src/compiler/types.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,16 +2312,19 @@ namespace ts {
23122312
/* @internal */ identifierCount: number;
23132313
/* @internal */ symbolCount: number;
23142314

2315-
// File level diagnostics reported by the parser (includes diagnostics about /// references
2315+
// File-level diagnostics reported by the parser (includes diagnostics about /// references
23162316
// as well as code diagnostics).
23172317
/* @internal */ parseDiagnostics: Diagnostic[];
23182318

2319-
// Stores additional file level diagnostics reported by the program
2320-
/* @internal */ additionalSyntacticDiagnostics?: Diagnostic[];
2321-
2322-
// File level diagnostics reported by the binder.
2319+
// File-level diagnostics reported by the binder.
23232320
/* @internal */ bindDiagnostics: Diagnostic[];
23242321

2322+
// File-level JSDoc diagnostics reported by the JSDoc parser
2323+
/* @internal */ jsDocDiagnostics?: Diagnostic[];
2324+
2325+
// Stores additional file-level diagnostics reported by the program
2326+
/* @internal */ additionalSyntacticDiagnostics?: Diagnostic[];
2327+
23252328
// Stores a line map for the file.
23262329
// This field should never be used directly to obtain line map, use getLineMap function instead.
23272330
/* @internal */ lineMap: number[];

0 commit comments

Comments
 (0)