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.

貢獻者指南