microsoft / microsoft/TypeScript
RegExp named capture groups don't get transpiled
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
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:
https://github.com/microsoft/TypeScript/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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der Verarbeitung von Reguläre-Ausdrücke-Literalen durch den TypeScript-Compiler und reproduziere das Problem im verlinkten Playground mit dem Ziel ES5. Vergleiche das angeforderte Verhalten mit der verlinkten Babel-Transformation und dem zugehörigen Issue #31241; abgeschlossen ist die Aufgabe, wenn benannte Capture-Gruppen für das Ziel korrekt behandelt werden oder das Issue klar dokumentiert, warum TypeScript sie nicht transformieren wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 30/100