Skip to content

Generators compiled with --target es5 --lib esnext do not support iterator helpers #59513

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

Closed
rbuckton opened this issue Aug 2, 2024 · 0 comments Β· Fixed by #59514
Closed

Generators compiled with --target es5 --lib esnext do not support iterator helpers #59513

rbuckton opened this issue Aug 2, 2024 · 0 comments Β· Fixed by #59514
Assignees
Labels
Committed The team has roadmapped this issue Suggestion An idea for TypeScript

Comments

@rbuckton
Copy link
Member

rbuckton commented Aug 2, 2024

πŸ”Ž Search Terms

generator iterator helper map esnext prototype

πŸ•— Version & Regression Information

⏯ Playground Link

https://www.typescriptlang.org/play/?target=1&lib=lib.esnext.d.ts&ts=5.6.0-beta#code/PTAEAEBcEMCcHMCmkBcpEGcCsAoEEAbASwCM1MA7RAD0hxwGMB7CjSUOUAXlAG0BGADSgATMIDMwgCwBdANw44AOgBu0AgFdMACgCUSgLbQADtqLcAfKHMAqUbrmh8vMaCnCAbMIAcM+gDMNCgZIIhZQO389UABvHFBQAE8iRAIAEwi+IVEJaXkcAF8cKP0jU3MuK1t7R3xYINCDRHRYWCZYNAByKKVe0pNO6wxQCiZ2aFBA4NCWIA

πŸ’» Code

// @target: es5
// @lib: esnext

const ar = [1, 2, 3, 4];
ar.values().map(i => i * 2); // [2, 4, 6, 8]

function * f() {
  yield * [1, 2, 3, 4];
}
f().map(i => i * 2); // error: 'f(...).map' is not a function

πŸ™ Actual behavior

The last line above throws even when Iterator.prototype is present, be it from the host or a polyfill.

πŸ™‚ Expected behavior

The last line above should not throw when the global Iterator.prototype is present and can be used as a prototype.

Additional information about the issue

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Committed The team has roadmapped this issue Suggestion An idea for TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants