Repository navigation
fix(asi): add semicolon before class members named in or instanceof - #80
Merged
acutmore merged 1 commit intoNov 18, 2026
Merged
Conversation
When a removed modifier (private, public, protected, readonly, override)
is in front of a member named `in` or `instanceof`, and the previous
field has an initializer without a semicolon, the member name was read
as a binary operator that continues that initializer:
f = a
private in = 1 -> f = a in = 1 (SyntaxError)
f = a
private in
b -> f = a in b (valid JS, wrong fields)
Treat these names like computed names and generator methods and start
the blanked modifier with a semicolon.
Signed-off-by: Mradul Singh <msingh@dealmeridian.com>
acutmore
approved these changes
Nov 18, 2026
Collaborator
|
thanks @bardrop! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #79
A class member named
inorinstanceofwith a removed modifier in front of it could continue the previous field's initializer when that field has no;:With
private infollowed by a fieldb, the output was valid JS but read as one fieldf = (a in b).The fix treats these two names like computed names and generator methods: the first removed modifier is replaced by a
;. This is done in bothvisitPropertyDeclarationandvisitFunctionLikeDeclaration(methods namedin()/instanceof()have the same problem).Testing:
tests/fixture/cases/asi.ts(field with initializer, field with type annotation, two methods).npm testfails onmain(expected: ' ; in = 1') and passes with the fix (43/43).npm run checkandnpm run format:checkpass.public 'in' = 1(string name) gets no;.