microsoft / microsoft/TypeScript

RegExp named capture groups don't get transpiled

オープン
#36,132 コメント 1 件 リアクション 13 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

In Discussion Suggestion
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

TypeScript コンパイラーによる正規表現リテラルの処理から始め、ES5 を対象に、リンク先の Playground で問題を再現してください。要求された動作をリンク先の Babel 変換および関連する issue #31241 と比較してください。対象に対して名前付きキャプチャグループが正しく処理されるか、または TypeScript がそれらを変換しない理由を issue に明確に記録できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
compilers
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。