microsoft / microsoft/TypeScript

Generator helper should include [Symbol.toStringTag]

オープン
#35,833 コメント 8 件 リアクション 2 件 担当者 1 名 GitHub で見る

@rbuckton がすでに取り組んでいます。

2020年1月14日 から。

Needs Investigation
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

TypeScript Version: 3.8.0-dev.20191223 and 3.7.3

Search Terms:

Generator, toStringTag, transformer, helper, tslib

Code

The following code will error in when using compilerOptions.target = es5, but works correctly when compiled with target = es2015 or greater.

// index.ts
function* f() {}
if (f()[Symbol.toStringTag] !== 'Generator') {
	  throw new Error("Bad generator!")
}
console.log('👍 Works well!');
tsc --target es5 --lib dom,es5,es2015 ./index.ts && node index.js
# Error: Bad generator!
tsc --target es2015 ./index.ts && node index.js
# 👍Works well!

Expected behavior:

The property should be set as expected via the helpers.

Generators should include the Symbol.toStringTag property "Generator" according to spec.

Some libraries check for a generator by inspecting this property. For example, @wordpress/redux-routine checks for this property and does not correctly handle generators produced by the helper.

regenerator-runtime is a widely used generator helper which does set this property.

Actual behavior:

Symbol.toStringTag is not included on the generator.

Playground Link:

Broken with target=es5
Working with target=es2015

Related Issues:

#19006

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

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

はじめの一歩

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

評価

この issue はまだ評価されていません。

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

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