-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
ES6Relates to the ES6 SpecRelates to the ES6 SpecWon't FixThe severity and priority of this issue do not warrant the time or complexity needed to fix itThe severity and priority of this issue do not warrant the time or complexity needed to fix it
Milestone
Description
TypeScript Version: 2.3.0-dev.20170407
function* myGeneratorFunction() {
yield 1;
return 2;
}
console.log(myGeneratorFunction.constructor.name);
Expected behavior:
Code logs "GeneratorFunction" when compiled to ES5.
Actual behavior:
Code logs "Function" when compiled to ES5.
Description:
Babel compiles this code so that the constructor name is set correctly. They do that by including a small run-time function that marks all generator functions as such. The source code for the marking function can be found here.
Compiling this per the specification is important since using the constructor name is the only way to check if a certain function is a generator function or not. See for instance this SO question and answer.
limemloh, shadeglare, KatSick, nickbreaton and a-tarasyuk
Metadata
Metadata
Assignees
Labels
ES6Relates to the ES6 SpecRelates to the ES6 SpecWon't FixThe severity and priority of this issue do not warrant the time or complexity needed to fix itThe severity and priority of this issue do not warrant the time or complexity needed to fix it