Why would I use TypeScript and Babel together? [closed] Why would I use TypeScript and Babel together? [closed] javascript javascript

Why would I use TypeScript and Babel together? [closed]


In my opinion you transpile TypeScript code to ES6 by using typescript and then re-transpile it to es5/es3 using babel to use in most javascript run times. Now because typescript compiler gives you es6 javascript you can do tree-shaking which is only supported for es6 module. And after tree-shaking your es6 javascript you can now compile it down to es5 to be able to used by most of the javascript run times out there.

Basically

  1. Compile ts to js-es6

tsconfig

{  "compilerOptions": {    "target": "es6"  }}
  1. tree shake or dead code elimination in es6 javascript

Tree ShakingUsing rollup etc

  1. Transpile to es5 javascript to be able to run in most of the javascript runtimes

.babelrc

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