Typescript: Support for --target ES2018

Created on 5 Dec 2017  路  13Comments  路  Source: microsoft/TypeScript

As TC39 gets ready to finalize ES2018, we should allow pass through for some transformation now only enabled under --target ESNext, here is the list:

Disable transforms for:

  • [ ] Rest/Spread Properties
  • [ ] async generators/for await ... of

We also need some new lib definitions:

  • [x] Promise finally (https://github.com/Microsoft/TypeScript/issues/20411)

The support for --target ES2018 was added in https://github.com/Microsoft/TypeScript/pull/20385

Bug ES2018 help wanted

Most helpful comment

Is there any progress on this?

Node.js 10.0.0 now supports 100% of ES2018, but only 8% of ESNEXT. So when targeting Node.js 10.x I would like to use e.g. native async iterators.

Using tsc --target es2018 --lib es2018 file.ts doesn't work for async iterators though. You need to add ,esnext.asynciterables to --lib, and target esnext instead, however doing this would then potentially enable and emit things that aren't supported on Node.js 10.x.

Would love to contribute PRs if there is a clear path forward 馃檶

All 13 comments

// CC: @bterlson

// CC: @benbraou

Just keep in mind that until a proposal shows up here it's not on the train for 2018.

Promise.prototype.finally, rest/spread properties and async iterable made it. Optional catch binding didn't.

@mhegazy optional catch binding is still stage 3 (https://github.com/tc39/proposals) and browserify can't compile it. This transform should be kept with es2018.

@falsandtru I've removed * [ ] optional catch binding

Thanks!

Is there any progress on this?

Node.js 10.0.0 now supports 100% of ES2018, but only 8% of ESNEXT. So when targeting Node.js 10.x I would like to use e.g. native async iterators.

Using tsc --target es2018 --lib es2018 file.ts doesn't work for async iterators though. You need to add ,esnext.asynciterables to --lib, and target esnext instead, however doing this would then potentially enable and emit things that aren't supported on Node.js 10.x.

Would love to contribute PRs if there is a clear path forward 馃檶

A PR would be appreciated. we need to split the transforms to their own file, and pipe the target flag through.

Haven't worked with the TS code base before, but would be happy to start!

If you have it in your head, some quick links to which files should be changed would be very much appreciated 鉂わ笍

here is the PR that added ES2017 target, you can use it as a reference: https://github.com/Microsoft/TypeScript/pull/11407

and another feature: https://github.com/Microsoft/TypeScript/issues/23801 could(maybe) split too

Now that ES2019 is around the corner, it would be a good time for this to be worked on, heck someone made a PR for ES2019 already.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rwyborn picture rwyborn  路  210Comments

OliverJAsh picture OliverJAsh  路  242Comments

sandersn picture sandersn  路  265Comments

jonathandturner picture jonathandturner  路  147Comments

blakeembrey picture blakeembrey  路  171Comments