Repository navigation
fix: blank type syntax in computed class field keys before the annotation - #78
Merged
acutmore merged 1 commit intoNov 13, 2026
Merged
Conversation
…tion
A class field with type syntax in a computed key and a type annotation,
`?` or `!` after it, produced invalid JavaScript:
[k as "x"]: number = 1; // emitted as `[k as "x"] ]: number = 1;`
visitPropertyDeclaration blanked the postfix token and the annotation
before visiting the name, so BlankString got its ranges out of source
order. Visit the name first.
Fixes #77
Signed-off-by: Mradul Singh <msingh@dealmeridian.com>
acutmore
approved these changes
Nov 12, 2026
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 #77
A class field whose computed key has type syntax (
as,satisfies,!,f<T>()) and that also has a type annotation,?or!gave invalid JavaScript:was emitted as
[k as "x"] ]: number = 1;.visitPropertyDeclarationblanked the postfix token and the annotation before it visited the name, soBlankStringgot its ranges out of source order. This change visits the name first, right after the modifiers. Methods and accessors were not affected (they already visit the name first).Testing:
tests/fixture/cases/b.ts(as+ annotation + initializer,static+as+?,f<T>()+!) and regenerated the fixtures withnpm run fixtures. Onlyb.jschanges. Theb.tsfixture fails onmainand passes with this change.[k ] = 1;.npm run check,npm run format:checkandnpm test(43 tests) pass.