5 ms·
Now that typescript can compile generators down to ES5 and ES3, you could reasonably replace Babel by tsc entirely, right? I mean, with its --allowJs flag it's
by skrebbel 10y ago
Now that typescript can compile generators down to ES5 and ES3, you could reasonably replace Babel by tsc entirely, right? I mean, with its --allowJs flag it's really just a javascript transpiler. Async/await, generators, JSX, array/object spread, destructuring.. it's all in there.
Did anyone try this? We're doing a hybrid babel/ts app and it wouldn't hurt ditching one of the two tools.
- kervin 10y agoYou still need to provide some polyfills
- WorldMaker 10y agoThat might be a great idea for a plugin: add warnings/errors and automatic code fixes to import core-js (or similar) polyfills based on code usage.
- tills13 10y agoI've replaced Babel all together for an app using webpack - I use the unfortunately named https://github.com/s-panferov/awesome-typescript-loader https://github.com/s-panferov/awesome-typescript-loader If there's something you really need in Babel, you can always transpile to ES6, then put it through Babel.
- mythz 10y agoRight I've never needed to use Babel, webpack + TS is now my choice combo. Being able to use latest ES6/7 features is one of the main reasons why I now use TypeScript for all my JS projects, even small ones that contain minimal Type annotations.
- Karupan 10y agoThat's exactly what I've been doing since 2.1 came out. We get to use async/await, object spread etc but still get it compiled to ES5. Haven't had any trouble getting it working with React either. It did need some tweaking to the tsconfig.json file, but that's a one time setup.