Report jsdoc syntax errors when checkJs is on

This commit is contained in:
Nathan Shively-Sanders 2017-05-30 13:32:46 -07:00
parent f938caf8c8
commit 2dd6627022
3 changed files with 17 additions and 5 deletions

View file

@ -6322,6 +6322,12 @@ namespace ts {
comment.parent = parent;
}
if (isInJavaScriptFile(parent)) {
if (!sourceFile.jsDocDiagnostics) {
sourceFile.jsDocDiagnostics = [];
}
sourceFile.jsDocDiagnostics.push(...parseDiagnostics);
}
currentToken = saveToken;
parseDiagnostics.length = saveParseDiagnosticsLength;
parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode;

View file

@ -1021,6 +1021,9 @@ namespace ts {
if (isSourceFileJavaScript(sourceFile)) {
if (!sourceFile.additionalSyntacticDiagnostics) {
sourceFile.additionalSyntacticDiagnostics = getJavaScriptSyntacticDiagnosticsForFile(sourceFile);
if (isCheckJsEnabledForFile(sourceFile, options)) {
sourceFile.additionalSyntacticDiagnostics = concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.jsDocDiagnostics);
}
}
return concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.parseDiagnostics);
}

View file

@ -2312,16 +2312,19 @@ namespace ts {
/* @internal */ identifierCount: number;
/* @internal */ symbolCount: number;
// File level diagnostics reported by the parser (includes diagnostics about /// references
// File-level diagnostics reported by the parser (includes diagnostics about /// references
// as well as code diagnostics).
/* @internal */ parseDiagnostics: Diagnostic[];
// Stores additional file level diagnostics reported by the program
/* @internal */ additionalSyntacticDiagnostics?: Diagnostic[];
// File level diagnostics reported by the binder.
// File-level diagnostics reported by the binder.
/* @internal */ bindDiagnostics: Diagnostic[];
// File-level JSDoc diagnostics reported by the JSDoc parser
/* @internal */ jsDocDiagnostics?: Diagnostic[];
// Stores additional file-level diagnostics reported by the program
/* @internal */ additionalSyntacticDiagnostics?: Diagnostic[];
// Stores a line map for the file.
// This field should never be used directly to obtain line map, use getLineMap function instead.
/* @internal */ lineMap: number[];