Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RegExp named capture groups don't get transpiled #36132

Open
cascornelissen opened this issue Jan 10, 2020 · 1 comment
Open

RegExp named capture groups don't get transpiled #36132

cascornelissen opened this issue Jan 10, 2020 · 1 comment
Labels
In Discussion Not yet reached consensus Suggestion An idea for TypeScript

Comments

@cascornelissen
Copy link

cascornelissen commented Jan 10, 2020

TypeScript Version:
3.7.2 (3.7.4 and nightly (3.8.0) as well)

Search Terms:
Named capture groups
Named capturing groups
Regex
ES2018.RegExp

Expected behavior:
The named capture group in the regex gets transpiled to the correct target (es5 in our case). Something like what @babel/plugin-transform-named-capturing-groups-regex does?

Actual behavior:
The named capture group ends up in the compiled code while only Chrome currently supports this.

Related Issues:
#31241

Code

const regex = /^(?<name>[A-Za-z]+)/;
const match = regex.exec('MatchThis-NotThis');
console.log(match);

Live Playground
Here

Additional information
I'm not 100% sure if this is something that TypeScript actually should be doing so if that's not the case I'd like to get some details on how to properly transpile this.

@RyanCavanaugh
Copy link
Member

We don't currently inspect RegEx bodies to see if they're compatible with the current target, since this is the first (?) new syntax in a long time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
In Discussion Not yet reached consensus Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants