Microsoft/TypeScript

TS1508: Unexpected '?'. Did you mean to escape it with backslash? shouldn't report even with `v` flag

クローズ

#62,707 opened on 2025/11/02

 (6 件のコメント) (0 件のリアクション) (0 人の担当者)TypeScript (13,395 件のフォーク)batch import
BugDomain: ParserHelp Wanted

Repository metrics

Stars
 (108,860 個のスター)
PR merge metrics
 (平均マージ 6d 17h) (30d で 9 merged PRs)

説明

🔎 Search Terms

TS1508, "Did you mean to escape it with backslash?"

🕗 Version & Regression Information

⏯ Playground Link

https://www.typescriptlang.org/play/?target=11#code/PQbQ-AZAusBuBQQ

💻 Code

/[?&]/v

🙁 Actual behavior

The error "TS1508: Unexpected '?'. Did you mean to escape it with backslash?" is given.

🙂 Expected behavior

No error because ? doesn't need to be escaped in a character class even with a v flag.

Additional information about the issue

Other characters like { do need escaping with the v flag, but ? gets no runtime errors, so I don't see why this has to err now.

コントリビューターガイド