Version
Reproduced on 5.5 through 7.0.2. Present since #55600 introduced regex syntax checking.
Playground
https://www.typescriptlang.org/play/?target=9#code/PTAEHEEMBcFMBNQGMD2AnNsnQDYE9RAUAlGgAsBLAZ1ABEB5AUQGVRYN0AoVAO0ulABuAMRyQA5qAC8oYAG0AOgAcA3gBkAvgF1gAgNygDho8ZOmTIUABUmARgCsABhsAuUJgCOAV3KZqsSgBMDgEALBwcFgByKPxiMAhEJKT+sKCUpCieOIhsaOigAEae-PAo3ADk0FxlfKDwnoqRkAC2-lIyABQA-AA8eAB88vDKIeoAlAC0Q8oB6gA+07PywN19g8OjY8D6BhbMQQF21bz8zSjw5ABm5GzU0itd5M6QBUhbO2afXzJg+8F2QA
Code
// target: ES2022
// Gated correctly — this DOES error
const vFlag = /[\p{L}]/v; // TS1501: requires es2024
// Not gated — these should error but don't
const dupNames = /(?<y>\d{4})-\d{2}|\d{2}\/(?<y>\d{4})/; // ES2025
const modifiers = /(?i:abc)/; // ES2025
Actual behavior
Only vFlag errors. Verified at es2018, es2020, es2022, es2024 — the two ES2025 patterns pass at every target.
modifiers also passes at es2017, meaning it has no gate at all.
Both fail at module load time on Node 22 (V8 12.4):
SyntaxError: Invalid regular expression: ... Duplicate capture group name
SyntaxError: Invalid regular expression: /(?i:abc)/: Invalid group
Expected behavior
An error consistent with how other regex features are gated:
| Regex feature |
Introduced |
Gate |
| Named capturing groups |
ES2018 |
TS1503 |
d flag |
ES2022 |
TS1501 |
v flag |
ES2024 |
TS1501 |
| Duplicate named groups |
ES2025 |
none |
| Pattern modifiers |
ES2025 |
none |
Notes
TypeScript already parses and validates both features — TS1515 (mutual exclusivity) and TS1500/TS1509 (flag rules) fire correctly. Only the version gate is missing.
Downleveling is not a prerequisite: named capturing groups are gated without being rewritten, so the same approach applies.
Both features were Stage 3 with no assigned ES version when #55600 was merged, which likely explains the omission. Both reached Stage 4 and shipped in ES2025.
Suggested locations, next to the existing validation:
scanGroupName — where the mutual-exclusivity error is reported
scanPatternModifiers — currently calls checkRegularExpressionFlagAvailability for individual flags only, not for the modifier syntax itself
Impact
Mainly affects library code. Bundlers that do not rewrite regexes (rolldown/oxc) emit the pattern as-is, so Node.js < 23 fails when the module is loaded — the failure surfaces in consumers' builds rather than in the authoring package.
Related
Version
Reproduced on 5.5 through 7.0.2. Present since #55600 introduced regex syntax checking.
Playground
https://www.typescriptlang.org/play/?target=9#code/PTAEHEEMBcFMBNQGMD2AnNsnQDYE9RAUAlGgAsBLAZ1ABEB5AUQGVRYN0AoVAO0ulABuAMRyQA5qAC8oYAG0AOgAcA3gBkAvgF1gAgNygDho8ZOmTIUABUmARgCsABhsAuUJgCOAV3KZqsSgBMDgEALBwcFgByKPxiMAhEJKT+sKCUpCieOIhsaOigAEae-PAo3ADk0FxlfKDwnoqRkAC2-lIyABQA-AA8eAB88vDKIeoAlAC0Q8oB6gA+07PywN19g8OjY8D6BhbMQQF21bz8zSjw5ABm5GzU0itd5M6QBUhbO2afXzJg+8F2QA
Code
Actual behavior
Only
vFlagerrors. Verified ates2018,es2020,es2022,es2024— the two ES2025 patterns pass at every target.modifiersalso passes ates2017, meaning it has no gate at all.Both fail at module load time on Node 22 (V8 12.4):
Expected behavior
An error consistent with how other regex features are gated:
dflagvflagNotes
TypeScript already parses and validates both features — TS1515 (mutual exclusivity) and TS1500/TS1509 (flag rules) fire correctly. Only the version gate is missing.
Downleveling is not a prerequisite: named capturing groups are gated without being rewritten, so the same approach applies.
Both features were Stage 3 with no assigned ES version when #55600 was merged, which likely explains the omission. Both reached Stage 4 and shipped in ES2025.
Suggested locations, next to the existing validation:
scanGroupName— where the mutual-exclusivity error is reportedscanPatternModifiers— currently callscheckRegularExpressionFlagAvailabilityfor individual flags only, not for the modifier syntax itselfImpact
Mainly affects library code. Bundlers that do not rewrite regexes (rolldown/oxc) emit the pattern as-is, so Node.js < 23 fails when the module is loaded — the failure surfaces in consumers' builds rather than in the authoring package.
Related