Skip to content

Expected token errors should display all expected tokens, not just the firstΒ #43467

Open
@sandersn

Description

@sandersn

πŸ•— Version & Regression Information

Pretty sure this has been the behaviour since the rewrite.

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

function a0([a, b, [[c]]]: [number, number, string[][]]) { }
a0([1, 2, [["world"]]);

πŸ™ Actual behavior

On the last ), "Expected ','."

πŸ™‚ Expected behavior

On the last ), "Expected ',' or ']'."

Right now the parser only shows the first error that starts at each location. This is an OK approach, especially when parsing has gone badly wrong, but often the parser will expect multiple tokens. The parser should report all the tokens in one error that were previously issued as multiple Expected_0 errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Effort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Experience EnhancementNoncontroversial enhancementsHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions