Repository navigation
Conversation
An index signature with a modifier can follow a field initializer that
has no `;`. Erasing it left the next member able to continue the
initializer:
f = a
static [key: string]: any
[x] = 1 -> f = a[x] = 1 (valid JS, wrong fields)
Index signatures are now blanked like other erased class members, so a
`;` is inserted when the previous member needs one.
Signed-off-by: Laksh Agarwal <184763813+Lotion-3@users.noreply.github.com>
This branch has not been deployed
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.
A class index signature with a modifier can follow a field whose initializer has no
;. It was erased withblankExact, so the next member could continue the initializer:With
readonly [key: number]: anyfollowed by["m"]() {}or*gen() {}, the output is a SyntaxError. TypeScript reports no diagnostics for these inputs, andonErrorisn't called.Index signatures are now erased with
blankStatement, like the erased method signatures in #74.Testing:
tests/fixture/cases/asi.ts. They fail onmainand pass with the fix.a.tsfollows a method body, so it now also starts with a;, as an erased method signature already does in that position.npm run checkpasses.npm test: 41/43; the two loader tests fail the same way onmainon my Windows machine.tsc's on about 52,000 generated class bodies (previous member × erased member × modifiers × next member) that TypeScript accepts without errors. Onmain, 447 differ, all with index signatures; with this change, none do.