Why should I use TypeScript and Babel together?

We have built-in record automation that runs on NPM and NodeJS. I completely agree with the automation of some conversion steps to get TypeScript and Babel, working together. I'm just wondering what the benefits will be. Can anyone tell me? It seems that since TS has added ES6 support, you really don't need Babel. The only thing that seems likely is, rather, Babylon, which supports new features, but TS seems to be too far behind now.

Did I miss something?

+5
source share
1 answer

In my version, you pass TypeScript code to ES6 using typescript , and then re-drag it to es5/es3 using babel to use it in most javascript cases. Now, since the TypeScript compiler gives you es6 javascript, you can do tree-shaking , which is only supported for the es6 module. And after es6 javascript your es6 javascript you can now compile it to es5 so that it can be used by most javascript runtimes.

Basically

1) Compile ts in js-es6

TSconfig

 { "compilerOptions": { "target": "es6" } } 

2) destroying a tree or destroying dead code in es6 javascript

Shaking a tree Using rollup, etc.

3) Move javascript to es5 to be able to run most of the time javascript runs

.babelrc

 { "presets": [ "es-2015", "stage-2" ] } 
+5
source

All Articles