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

Allow for class static vars to be called static #44813

Merged
merged 3 commits into from
Oct 1, 2021
Merged

Conversation

orta
Copy link
Contributor

@orta orta commented Jun 29, 2021

Fixes #43836 - due to the implementation of #41127 which ended up triggering the bug

Now you can have a static variable called static, and code like static static p: string doesn't work because that's static static and p: string but you need to add a ; to correctly disambiguate.

/cc @weswigham

@orta orta requested review from sandersn and weswigham June 29, 2021 18:43
@orta orta self-assigned this Jun 29, 2021
@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Jun 29, 2021
@sandersn
Copy link
Member

sandersn commented Jul 8, 2021

To make sure I understand correctly, this PR allows declaration of static properties named static if they're formatted like so

static
static

at the cost of a non-specific error message in case of duplicated static keywords -- the new message kind of assumes that you meant to declare a property named static, followed by a static property named p. Is that correct?

@weswigham
Copy link
Member

Essentially yes - since you can only have one static modifier, and you're allowed to have a static property named static.

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.

I'm not a huge fan of losing the specific static static p error message, so maybe it's possible to follow up with code that returns it.

Given how complex this fix is, though, it's probably not worth it. It would mainly help people with batch compiles with lots of errors anyway.

}

class C5 {
static static
Copy link
Member

Choose a reason for hiding this comment

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

can I see an example with an initialiser, and one with a type?

@orta
Copy link
Contributor Author

orta commented Oct 1, 2021

OK, let's get this in as it's been reviewed and we felt pretty confident with it

@orta orta merged commit 016d78b into microsoft:main Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Unexpected ASI after static in class
4 participants