Microsoft/TypeScript

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

Open

#43,467 创建于 2021年3月31日

在 GitHub 查看
 (0 评论) (0 反应) (0 负责人)TypeScript (6,726 fork)batch import
Effort: ModerateExperience EnhancementHelp Wanted

仓库指标

Star
 (48,455 star)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 9 个 PR)

描述

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

贡献者指南