-
Notifications
You must be signed in to change notification settings - Fork 13k
Fix for #11719 - TSServer: JS files should display syntactic errors for TS syntax #11848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…only constructs from within a JavaScript file as syntactic errors.
// For JavaScript files, we report semantic errors for using TypeScript-only | ||
// constructs from within a JavaScript file as syntactic errors. | ||
if (isSourceFileJavaScript(sourceFile) && !sourceFile.parseJavaScriptDiagnostics) { | ||
sourceFile.parseJavaScriptDiagnostics = getJavaScriptSemanticDiagnosticsForFile(sourceFile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change the name to getJavaScriptSyntacticDiagnosticsForFile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
// constructs from within a JavaScript file as syntactic errors. | ||
if (isSourceFileJavaScript(sourceFile) && !sourceFile.parseJavaScriptDiagnostics) { | ||
sourceFile.parseJavaScriptDiagnostics = getJavaScriptSemanticDiagnosticsForFile(sourceFile); | ||
sourceFile.parseDiagnostics = sourceFile.parseDiagnostics.concat(sourceFile.parseJavaScriptDiagnostics); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would not change the parseDiagnostics here.
if (isSourceFileJavaScript(sourceFile) && !sourceFile.parseJavaScriptDiagnostics) { | ||
sourceFile.parseJavaScriptDiagnostics = getJavaScriptSemanticDiagnosticsForFile(sourceFile); | ||
sourceFile.parseDiagnostics = sourceFile.parseDiagnostics.concat(sourceFile.parseJavaScriptDiagnostics); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider changing it to:
if (isSourceFileJavaScript(sourceFile))
if (!sourceFile.additionalSyntacticDiagnostics) {
sourceFile.additionalSyntacticDiagnostics = getJavaScriptAdditionalSyntacticDiagnosticsForFile(sourceFile);
}
return concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.parseDiagnostics);
}
return sourceFile.parseDiagnostics;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good - done
… has changed due to concatenation changes
Fix for #11719 - TSServer: JS files should display syntactic errors for TS syntax
For JavaScript files, report semantic errors for using TypeScript-only constructs from within a JavaScript file as syntactic errors.