Skip to content
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

getJSSyntacticDiagnosticsForFile: minor cleanup #29208

Closed
wants to merge 1 commit into from

Conversation

ajafff
Copy link
Contributor

@ajafff ajafff commented Dec 30, 2018

ConstKeyword is not specific to TypeScript syntax, therefore it doesn't need to be checked there.

This function doesn't abort if cancellation is requested, so it doesn't need to be wrapped in runWithCancellationToken. And even if it used the cancellation token, the checker wouldn't be in an invalid state.

This change is best viewed without whitespace changes: https://github.com/Microsoft/TypeScript/pull/29208/files?w=1

@RyanCavanaugh
Copy link
Member

What's the originating issue here?

@RyanCavanaugh RyanCavanaugh self-assigned this Jan 25, 2019
@RyanCavanaugh RyanCavanaugh added this to the Community milestone Jan 25, 2019
@ajafff
Copy link
Contributor Author

ajafff commented Jan 25, 2019

This just removes some unnecessary code I discovered while reading through the implementation.
There's no observable difference in behavior. It may result in a small performance improvement.

@RyanCavanaugh
Copy link
Member

@sandersn please verify

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

Looks good; just one small question.

for (const modifier of modifiers) {
switch (modifier.kind) {
case SyntaxKind.ConstKeyword:
if (isConstValid) {
Copy link
Member

Choose a reason for hiding this comment

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

where is this checked if not here? I assume we're supposed to get an error for const on method declarations in both Javascript and Typescript.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why is const special?
As I see it this function reports Typescript syntax that is not valid in JS files and there's nothing TS specific about const.

What you really want is all grammar errors in TS and JS files. Hence I opened #29213 to propose exactly that.

Copy link
Member

Choose a reason for hiding this comment

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

So the const modifier check is otherwise handled in the checker's grammar errors?

I read #29213, and it makes sense, although syntactic errors block semantic errors (or did at one time), so we'd need to test that the editor experience doesn't get worse.

However, removing this check here would then remove the error in non-ts-tcheck JS files until #29213 is fixed, right? If that's the case we should wait until that is done before making this change.

Copy link
Member

Choose a reason for hiding this comment

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

I think at one point the logic of having grammar errors in semantic scenario was to be able to reuse the tree in incremental parsing and avoid extra pass as part of syntax diagnostics query. We would need to investigate if and what all changes are needed to even make sense if #29213 should be fixed or not.

@sandersn sandersn added the For Backlog Bug PRs that fix a backlog bug label Feb 1, 2020
@sandersn
Copy link
Member

This PR hasn't seen any activity for quite a while and is blocked on #29213, so I'm going to close it to keep the number of open PRs manageable. Feel free to open a fresh PR or continue the discussion there.

@sandersn sandersn closed this Mar 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants