3 ms·
Can typescript be integrated with other, standards-compliant preprocessors? It sounds irritating that Typescript 2.1 will "add" async/await when it's been avail
by woah 10y ago
Can typescript be integrated with other, standards-compliant preprocessors? It sounds irritating that Typescript 2.1 will "add" async/await when it's been available in Browserify and Babel for years already. I want to get into using js types, and typescript seems to have the most momentum, but I don't want to get locked into o e monolithic preprocessor which lags behind everything else by several years.
- DanRosenwasser 10y agoYes, you can just target ES6/ES2015 in your emit and TypeScript will use generators to enable `async` & `await`. You can then use Babel as the next step. We have a tutorial on Gulp & TypeScript that hooks up Babel and Browserify: https://www.typescriptlang.org/docs/handbook/gulp.html https://www.typescriptlang.org/docs/handbook/gulp.html
- deleted 10y ago[deleted]
- unscaled 10y agoTypescript actually already supports async/await since version 1.7, but only for ES6 targets - i.e. it compiles everything down to generator-based coroutines, which is essentially the same as the 'transform-async-to-generator' plugin in Babel, I guess. If you want to support ES5/3, I guess you can always target ES6 with Typescript and then feed the result to Babel. It's a bit clunky, but it would probably work. Where Babel shines vs. Typescript is that you get much more fine-grained control over which transformations to apply. Typescript doesn't seem to support just emitting async/await directly, which is what you would want if you target a browser which support async/await directly (Beta Chrome and Edge already support it behind a flag, and it's going to come to other browsers soon)