Repository navigation
feat: add support regexp buffer boundary assertions - #65486
Oleksandr Tarasiuk (a-tarasyuk) wants to merge 2 commits into
Conversation
|
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
| case 'A', 'z', 'Z': | ||
| if p.anyUnicodeMode { | ||
| p.incPos(1) | ||
| if p.scanner.languageVersion() < core.ScriptTargetESNext { |
There was a problem hiding this comment.
Should this be in the "features" list? (I had thought that's where we put all the regexp version info)
There was a problem hiding this comment.
Yes, I just wasn’t sure about moving LanguageFeature out of the checker to avoid importing from the scanner :)
There was a problem hiding this comment.
Er, I think i was just thinking of regExpFlagToFirstAvailableLanguageVersion no? I guess these aren't flags...
I didn't realize that actually we didn't check the other stuff at all, so I probably asked you for too much
There was a problem hiding this comment.
I didn’t use regExpFlagToFirstAvailableLanguageVersion because it seems to cover only flags, not assertions, so I decided to use a direct target check similar to
TypeScript/tsc/internal/scanner/regexp.go
Lines 262 to 264 in c04e140
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the regular-expression boundary assertion support.
No open issues 🎉
1 file not reviewed
tsc/internal/diagnostics/diagnostics_generated.go: Generated file
What changed in this PR
Adds native TypeScript compiler support for the proposed regular-expression buffer boundary assertions \A, \z, and \Z.
Changes:
- Recognizes the assertions in Unicode (
u/v) mode while preserving legacy identity escapes. - Requires ESNext and rejects direct quantification of the assertions.
- Adds compiler tests and diagnostic/emission baselines for ES2026 and ESNext.
| File | Description |
|---|---|
tsc/testdata/tests/cases/compiler/regularExpressionAssertions.ts |
Tests assertions, target restrictions, quantifiers, and escape handling. |
tsc/testdata/baselines/reference/compiler/regularExpressionAssertions(target=esnext).js |
Records unchanged regex emission for ESNext. |
tsc/testdata/baselines/reference/compiler/regularExpressionAssertions(target=esnext).errors.txt |
Records invalid quantifier and escape diagnostics. |
tsc/testdata/baselines/reference/compiler/regularExpressionAssertions(target=es2026).js |
Records unchanged regex emission for ES2026. |
tsc/testdata/baselines/reference/compiler/regularExpressionAssertions(target=es2026).errors.txt |
Records target restrictions and syntax diagnostics. |
tsc/internal/scanner/regexp.go |
Recognizes assertions and enforces target and quantifier rules. |
tsc/internal/diagnostics/diagnostics_generated.go |
Registers the generated ESNext-only diagnostic. |
tsc/internal/diagnostics/diagnosticMessages.json |
Defines the ESNext-only diagnostic message. |
tsc/internal/diagnostics/diagnosticMessages.generated.json |
Adds the generated localization entry. |
Review effort: Balanced
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the regular-expression buffer boundary assertion changes.
No open issues 🎉
1 file not reviewed
tsc/internal/diagnostics/diagnostics_generated.go: Generated file
Review effort: Balanced
15266c8 to
775e2f4
Compare
Adds support for https://github.com/tc39/proposal-regexp-buffer-boundaries