Microsoft/TypeScript

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

Open

#62.707 geöffnet am 2. Nov. 2025

Auf GitHub ansehen
 (6 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (6.726 Forks)batch import
BugDomain: ParserHelp Wanted

Repository-Metriken

Stars
 (48.455 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)

Beschreibung

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

Contributor Guide