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

[TypeScript] class implements Interface is broken #4125

Open
hyrious opened this issue Dec 31, 2024 · 0 comments · May be fixed by #4126
Open

[TypeScript] class implements Interface is broken #4125

hyrious opened this issue Dec 31, 2024 · 0 comments · May be fixed by #4126
Labels
C: Syntax T: bug A bug in an existing language feature

Comments

@hyrious
Copy link
Contributor

hyrious commented Dec 31, 2024

What happened?

interface B {}
const A = class implements B {
  readonly foo = 1
}

Screenshot:
image

It seems the word implements was identified as a class name, because JavaScript.sublime-syntax doesn't exclude it from reserved_word.

So the workaround is to give the scoped class a name:

const A = class A implements B {
  readonly foo = 1
}

FYI, my initial code was like this:

export foo: IFoo = new class implements IFoo {}
@deathaxe deathaxe added T: bug A bug in an existing language feature C: Syntax labels Dec 31, 2024
deathaxe added a commit to deathaxe/sublime-packages that referenced this issue Dec 31, 2024
Fixes sublimehq#4125

This commit adds "future reserved words" from [1] to prevent them being
scoped as normal identifiers which fixes anonymous class instantiations
in TypeScript.

They are also marked reserved in JavaScript as specified as such by [1],
and `implements` is scoped illegal in class declarations.

[1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#keywords
@deathaxe deathaxe linked a pull request Dec 31, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Syntax T: bug A bug in an existing language feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants