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

@piotrwitek I understand as much. The million dollar question now is: How?

I'm looking for a more TypeScript generic method than the somewhat questionable programmatic use in plugin-typescript for JSPM, where errors are apparently ignored. If there's an option somewhere that enables this, then at least it's a flaky strategy that I've chosen myself.

kdalgaard avatar Oct 11 '16 11:10 kdalgaard

@kdalgaard I have not tried it but I think the tsc option is --noEmitOnError = false, which is the default. I think even if tsc will yell at you and exit with error it will still emit what it can. I guess plugin-typescript does the same but without yelling at you or exiting with error.

jonaskello avatar Oct 11 '16 11:10 jonaskello

@jonaskello Can't seem to get it to work. Maybe something with my Webpack setup or trouble with TSLint...

How do you all become aware of actual script errors, if everything is output anyway?

kdalgaard avatar Oct 11 '16 12:10 kdalgaard

@kdalgaard I can describe my workflow if it helps. In my previous project I used webpack. Everything was compiled, type-checked and bundled in-memory using webpacks dev-server, and then it hit the browser. So when it hit the browser I was sure it compiled and was type-checked. In the beginning this was really fast. Now that project has grown, initial webpack build takes 36263ms and incremental takes 16981ms. So for my current project I decided to try jspm instead. Not sure if it is any better, but at least it is different :-). So I found @piotrwitek's jspm starter and did not really understand how that worked because it is so different from the webpack flow. Then I finally understood. You have to realise that code is not compiled, not type-checked and not bundled before hitting the browser. It is simply just transpiled, bascially it just strips the type information without caring about it. This makes it possible to have JS hitting the browser fast which makes it possible to make changes in TS and iterate really fast. But I had the same question as you, how do I know if there is a compile error? Well, you have to have a second place where you do that. For example you can use atom with the plugin that incrementially compiles and type-checks. Or you can simply use any editor and just run tsc --watch in the termial, which is what I do. So what I finally realised was that compiling/type-checking could be a separate concern to getting the JS into the browser. Granted this is very different from how webpack works and you have unlearn a bit. And of course this is not the only workflow for TS in jspm, it is just the one I have currently adopted.

jonaskello avatar Oct 11 '16 12:10 jonaskello

@jonaskello Thanks for the explanation. I would expect Webpack to continue being fast due to hot module replacement, but I don't know...

kdalgaard avatar Oct 12 '16 06:10 kdalgaard

@DanielRosenwasser @jonaskello As demonstrated by fast-async you don't need generators to support async/await, promises are enough. Please don't despair and implement async/await for es5 in typescript.. The the only thing that is blocking me to switch.

sheerun avatar Oct 19 '16 05:10 sheerun

@sheerun This issue it not about async/await. It is about generator functions. AFAIK async/await -> ES5 is already implemented in ts@next. Async/await is great if you are taking a imperative approach but IMO not useful if you are using a functional approach to side-effects such as redux-saga.

jonaskello avatar Oct 19 '16 05:10 jonaskello

@sheerun What @jonaskello said.

kdalgaard avatar Oct 19 '16 07:10 kdalgaard

Now that #5595 has landed, is there any chance this issue can make it back onto the roadmap?

jonaskello avatar Nov 09 '16 17:11 jonaskello

Looks like there is a chance: https://github.com/Microsoft/TypeScript/pull/12346

normalser avatar Nov 18 '16 14:11 normalser