- Error
- Reported by the lexer and parser
TS1499
Unknown regular expression flag.
A regular expression literal has a flag that doesn't exist. Use only `d`, `g`, `i`, `m`, `s`, `u`, `v` and `y`.
What it means
The letters after the closing / of a regular expression are its flags. Only d, g, i, m, s, u, v and y exist; any other letter is reported.
Example
export const re = /abc/x;
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(1,24): error TS1499: Unknown regular expression flag.
Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.
How to fix
- Remove the unknown flag. JavaScript has no
x(extended) flag; write the pattern without whitespace and comments.