-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: ParserThe parser didn't handle the syntax correctlyThe parser didn't handle the syntax correctlyHelp WantedYou can do thisYou can do this
Milestone
Description
🔎 Search Terms
TS1508, "Did you mean to escape it with backslash?"
🕗 Version & Regression Information
- This changed between versions ______ and _______
- This changed in Provide Syntax Checking for Regular Expressions #55600 which introduced regular expression syntax checking
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
- I was unable to test this on prior versions because _______
⏯ 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: ParserThe parser didn't handle the syntax correctlyThe parser didn't handle the syntax correctlyHelp WantedYou can do thisYou can do this