Microsoft/TypeScript

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

Open

#43 467 ouverte le 31 mars 2021

Voir sur GitHub
 (0 commentaires) (0 réactions) (0 assignés)TypeScript (6 726 forks)batch import
Effort: ModerateExperience EnhancementHelp Wanted

Métriques du dépôt

Stars
 (48 455 stars)
Métriques de merge PR
 (Merge moyen 6j 17h) (9 PRs mergées en 30 j)

Description

🕗 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.

Guide contributeur