Skip to content

Fix for #11719 - TSServer: JS files should display syntactic errors for TS syntax #11848

Merged
jramsay merged 3 commits into
masterfrom
AddJavaScriptSemanticErrorsToSyntacticErrors
Oct 28, 2016
Merged

Fix for #11719 - TSServer: JS files should display syntactic errors for TS syntax #11848
jramsay merged 3 commits into
masterfrom
AddJavaScriptSemanticErrorsToSyntacticErrors

Conversation

@jramsay
Copy link
Copy Markdown
Member

@jramsay jramsay commented Oct 26, 2016

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.

…only constructs from within a JavaScript file as syntactic errors.
@jramsay
Copy link
Copy Markdown
Member Author

jramsay commented Oct 26, 2016

// cc: @mhegazy, @vladima , @billti

Comment thread src/compiler/program.ts Outdated
// 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);
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread src/compiler/program.ts Outdated
// 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);
Copy link
Copy Markdown
Contributor

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.

Comment thread src/compiler/program.ts
if (isSourceFileJavaScript(sourceFile) && !sourceFile.parseJavaScriptDiagnostics) {
sourceFile.parseJavaScriptDiagnostics = getJavaScriptSemanticDiagnosticsForFile(sourceFile);
sourceFile.parseDiagnostics = sourceFile.parseDiagnostics.concat(sourceFile.parseJavaScriptDiagnostics);
}
Copy link
Copy Markdown
Contributor

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;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good - done

@jramsay jramsay merged commit 980f9fd into master Oct 28, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
@jakebailey jakebailey deleted the AddJavaScriptSemanticErrorsToSyntacticErrors branch November 7, 2022 17:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants