There is a TypeScript, Babel, React, and Karma Sample.
The Webpack config contains babel-loader with ts-loader for .tsx?
files.
Please explain why it is needed? Why isn't ts-loader enough?
ts-loader: convert typescript (es6)
to javascript (es6)
babel-loader: converts javascript (es6)
to javascript (es5)
and Typescript
doesn't do polyfills
, which babel
does. If you write client-side code in es6
and want it to run on modern browsers, you'd probably need babel
's polyfills
.
It is less justified with server-side code - just use the latest node
version for es6
support. But babel still provides some goodies that tsc
doesn't - like caching, or a huge range of plugins that can be very useful.
It's not necessary but a practice for using them all together.