TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

ES6 Generator support

Open wizzard0 opened this issue 11 years ago • 70 comments

This can be broken down to 3 areas:

  1. basic (parser) support, even if we lose typechecking locally
  2. Typechecking support
  3. Transpiling like facebook/regenerator or Traceur, for targeting ES3/ES5.

Any timelines on this?

wizzard0 avatar Dec 26 '14 15:12 wizzard0

@glen-84 The fact is that implementing async/await is alerady ridiculous. It is few years when they 'plan to implement it in next version'. Maybe they do not want to implement it at all, and just playing bad game with us ? Only IE 11- need this feature, because Chrome and FF have support to ES6, and cost of implementing is very high. Why to make serious investment for leagcy standard on legacy browser on legacy Windows (8.1-) ? Just use Babel of lambdas if you want support legacy tech. This may be line of thinking by TS team.

The 'new stuff' is null-check, but this is much less usefull than anybody wish. Preventing null exceptions lead to complex declarations on code and data structures. JS/TS code is very dynamic, most libraries aren't designed with non-null philosophy, and will cause leaks and serious resistance while bending to non-null behaviour. That's why most devs will stay with 'more risky but much simpler code'.

vbcodec avatar Jul 11 '16 14:07 vbcodec

@vbcodec there is much more 'new stuff' coming with 2.0 than just the null-check. For me, type declarations on this of any function is much more important, just as granular lib selection or the new typing resolution strategies are.

In any case, I would suggest not to flame this topic with irrelevant comments further, let's all patiently wait for an official response.

niieani avatar Jul 11 '16 16:07 niieani

As noted in today's release announcement, we are happy with the implementation we have today for async-await (see https://github.com/Microsoft/TypeScript/pull/9175). The PR is in final code review iterations; and we hope it will be merged in master within few weeks. once that is done, it should be available for the general public in the nightly releases (typescript@next).

mhegazy avatar Jul 11 '16 17:07 mhegazy

@mhegazy any news? is the merge imminent? Really looking forward to this feature release! :+1: :smile:

jamespacileo avatar Jul 26 '16 16:07 jamespacileo

Yes, we desperately need async/await for ES5 ...

HoosierMike avatar Jul 27 '16 15:07 HoosierMike

@HoosierMike desperate might be too much, but it does indeed feel like it! It overjoys me already to use async/await in ES6 node, can't wait to use it for ES5 frontend apps.

jamespacileo avatar Jul 27 '16 16:07 jamespacileo

I see it's on the roadmap for version 2.1 , but how to know if it is in nightly build yet ? I'm assuming that is when we can easily grab at the bits. Thanks

rybolt avatar Aug 24 '16 21:08 rybolt

Any ETA perhaps?

devzsolt avatar Sep 02 '16 13:09 devzsolt

@devzsolt https://github.com/Microsoft/TypeScript/pull/9175#issuecomment-244181037

glen-84 avatar Sep 02 '16 14:09 glen-84

great news, thanks @glen-84!

devzsolt avatar Sep 02 '16 17:09 devzsolt

Down-level generator support for async functions (async/await) is now in master and should be available via typescript@next tomorrow.

rbuckton avatar Sep 07 '16 01:09 rbuckton

@rbuckton Will this support also cover compiling ES6 generator functions (function*/yield) to ES5? I'm guessing it does but from the description it seems to be only about async/await.

jonaskello avatar Sep 07 '16 20:09 jonaskello

@jonaskello I saw that there was some work on partially down-leveling generator functions (not just async/await) in #10106, but that was apparently closed because the restrictions on what is and is not supported weren't clear (see #10307).

I think the idea is to implement just enough to transpile async/await, but not yet transpile all generator functions. That way, the TypeScript team can ship this feature sooner because it only needs partial support for generators. I believe full generator support is still somewhere on the roadmap, but simply for a later version. (Don't quote me on that though, I'm not part of the TypeScript team. I just follow their progress in some interesting PRs. :stuck_out_tongue: )

MattiasBuelens avatar Sep 07 '16 22:09 MattiasBuelens

If that is true then what has been merged into master does not solve this issue (which is titled ES6 Generator support). I had really hoped for generator function support. Maybe I am in the minority here but I have no use for async/await. I do all my side-effects in redux-saga which only uses generator functions. I guess one could argue that support for features that are part of ES2015 (generator functions) should be have priority over features that will be out in ES2017 (async/await). But still nice to see that progress is made in areas related to generator functions!

jonaskello avatar Sep 07 '16 22:09 jonaskello

Nit: async/await won't "maybe" be out, they are stage-4, which means they are standard. The annual spec publishing is a formality.

On Thu, Sep 8, 2016 at 07:30 Jonas Kello [email protected] wrote:

If that is true then what has been merged into master does not solve this issue (which is titled ES6 Generator support). I had really hoped for generator function support. Maybe I am in the minority here but I have no use for async/await. I do all my side-effects in redux-saga which only uses generator functions. One could argue that support for features that are part of ES6 (generator functions) should be have priority over features that will (maybe) be out in a later ES version (async/await). But still nice to see that progress is made in areas related to generator functions!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Microsoft/TypeScript/issues/1564#issuecomment-245439745, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEdfc7JxKejEJQ9azL0vwqBIAlI9SCzks5qnzrngaJpZM4DMZR_ .

Jessidhia avatar Sep 07 '16 23:09 Jessidhia

@Kovensky Sorry about that, I don't follow async/await that closely. Last I checked it was stage-3 but things move quickly :-). Updated my comment accordingly. And don't get me wrong, I used async/await in C# since it was a technical preview and it is a really nice feature.

jonaskello avatar Sep 08 '16 05:09 jonaskello

It would be great to use redux-saga with typescript and es6 generators.

http://yelouafi.github.io/redux-saga/

jotaoncode avatar Oct 01 '16 22:10 jotaoncode

@jotaoncode You could already do that if you want use webpack+babel+typescript for your build process, like so:

webpack.config.js

module: {
    loaders: [
        {
            test: /\.tsx?$/,
            loader: 'babel-loader!awesome-typescript-loader',
            // ...
        },
    ]
},

.babelrc

{
    "presets": ["es2015", "stage-0"],
    "plugins": ["transform-regenerator"]
}

This way you can use ES2015 Generators & Async/Await syntax in combination with redux-saga, and down-level compile the code to ES5 (which would then also run in IE11)

drywolf avatar Oct 02 '16 10:10 drywolf

@jotaoncode Seems like it is not going to happen, see #3975.

jonaskello avatar Oct 02 '16 17:10 jonaskello

@drywolf you are right, I saw your repo related to typescript webpack generator sample, also seems like they already fixed the problem related to awesome-typescript-loader, so probably the temporary fix you did is no longer needed. Many thanks for the help :)

jotaoncode avatar Oct 04 '16 21:10 jotaoncode