1

Closed

Accept yield syntax with --target ES6

description

node.js >= v0.11.2 have support for generators using the --harmony option so you can run this code: https://docs.google.com/file/d/0B4Qu_52vHH3jOHYxNXpfSDBrQ1k/view

Also you can use traceur-compiler to convert generators into plain ES3.

It would be great if typescript alowed that syntax to be valid adding an ES6 target or something (even if it doesn't generate ES3 code and consideers yield to return the any type). That would allow to have typings and autocompletion and using generators and linear async with generators.

In order to use generators we would need:
function*() { } and yield keyword.
Closed May 31, 2013 at 12:13 AM by billti

comments

soywiz wrote May 28, 2013 at 12:49 AM

yield could be just a function. Thought brackets are optional.
Something like:
declare var yield: (promise: Promise<T>) => T;

But the function*() syntax cant be avoided.

billti wrote May 31, 2013 at 12:12 AM

Thanks for the suggestion. Yield and other ES6 syntax is definitely on our radar for post-V1, However at this point there will be very little new in the language for TypeScript v1.0 beyond what is currently being developed in our 0.9.0 branches.