A quick guide on setting up Babel as a TypeScript compiler
To do this, we'll configure
tsc (the TypeScript compiler) only check types, but not emit files. We'll use Babel to do the actual compilation.
This only makes Babel ignore the types—it doesn't check them! For that, we'll use TypeScript's
tsc, which we'll get to later.
Configure TypeScript by creating a file called
tsconfig.json. Of particular interest here is
tsc to check types. This should print a few errors if you have any.
If you installed
@babel/cli, you can test building files using the
You can use Babel without Webpack or Rollup. If you're using already Webpack or Rollup, you can skip this; this is mostly ideal for writing small open-source libraries with limited compilation needs.
You can use
@babel/cli to compile files. In this example, we'll set up some NPM scripts to convert every TypeScript file in
This article was written for TypeScript 3.x and Babel 7.x. Here are some links for further reading: