[ts] enable support for iterators in browsers#22986
Conversation
8f60c3b to
be123de
Compare
This comment has been minimized.
This comment has been minimized.
Weird, when I ran |
This comment has been minimized.
This comment has been minimized.
…browser-iterator-support
5107716 to
ea64458
Compare
Similar tests in other PRs have failed so I created #23005 to move these tests to the jest integration suite. |
💚 Build Succeeded |
| "topojson-client": "3.0.0", | ||
| "trunc-html": "1.0.2", | ||
| "trunc-text": "1.0.2", | ||
| "tslib": "^1.9.3", |
There was a problem hiding this comment.
Is this supposed to be a devDependency? We only use the typescript runtime during development, correct?
There was a problem hiding this comment.
Nope, TypeScript will inject require statements for tslib when we use things like a for...of over an iterable, so tslib needs to be installed outside of dev too.
I was surprised when I tried to spread a `Set` in TypeScript and the browser complained about `Set.slice()` not being defined. This is because TypeScript does not automatically enable support for iterators when targeting earlier ES versions, like we do in the browser, unless you use the `"downlevelIteration": true` compiler option. This injects some helpers into the necessary files for reading/spreading iterators, which can be stuffed behind an import statement with using the `"importHelpers": true` compiler option and include `tslib` in our dependencies. This is already a dependency of several of our packages, so it shouldn't cause any additional modules.
I was surprised when I tried to spread a `Set` in TypeScript and the browser complained about `Set.slice()` not being defined. This is because TypeScript does not automatically enable support for iterators when targeting earlier ES versions, like we do in the browser, unless you use the `"downlevelIteration": true` compiler option. This injects some helpers into the necessary files for reading/spreading iterators, which can be stuffed behind an import statement with using the `"importHelpers": true` compiler option and include `tslib` in our dependencies. This is already a dependency of several of our packages, so it shouldn't cause any additional modules.
I was surprised when I tried to spread a `Set` in TypeScript and the browser complained about `Set.slice()` not being defined. This is because TypeScript does not automatically enable support for iterators when targeting earlier ES versions, like we do in the browser, unless you use the `"downlevelIteration": true` compiler option. This injects some helpers into the necessary files for reading/spreading iterators, which can be stuffed behind an import statement with using the `"importHelpers": true` compiler option and include `tslib` in our dependencies. This is already a dependency of several of our packages, so it shouldn't cause any additional modules.
I was surprised when I tried to spread a
Setin TypeScript and the browser complained aboutSet.slice()not being defined. This is because TypeScript does not automatically enable support for iterators when targeting earlier ES versions, like we do in the browser, unless you use the"downlevelIteration": truecompiler option. This injects some helpers into the necessary files for reading/spreading iterators, which can be stuffed behind an import statement with using the"importHelpers": truecompiler option and includetslibin our dependencies. This is already a dependency of several of our packages, so it shouldn't cause any additional modules.