React Webpack and TypeScript installation
The main components are (in addition to the standard entry, output and other webpack properties):
For this you need to create a rule that tests for the .ts and .tsx file extensions, specify ts-loader as the loader.
Resolve TS extensions
You also need to add the .ts and .tsx extensions in the resolve array, or webpack won't see them.
This is a minimal tsconfig to get you up and running.
Let's go through the properties one by one:
This is an array of source code. Here we have only one entry, src/*, which specifies that everything in the src directory is to be included in compilation.
Specifies that we want to compile to ES5 target
Setting this to true will make TypeScript automatically compile your tsx syntax from < div /> to React.createElement("div").
Handy property which will allow you to import node modules as if they are ES6 modules, so instead of doing import * as React from 'react'
you can just do
without any errors telling you that React has no default export.