React tsconfig.json


Example

This is a minimal tsconfig to get you up and running.

{
    "include": [
        "src/*"
    ],
    "compilerOptions": {
        "target": "es5",
        "jsx": "react",
        "allowSyntheticDefaultImports": true
    }
}

Let's go through the properties one by one:

include

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.

compilerOptions.target

Specifies that we want to compile to ES5 target

compilerOptions.jsx

Setting this to true will make TypeScript automatically compile your tsx syntax from <div /> to React.createElement("div").

compilerOptions.allowSyntheticDefaultImports

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'
const { Component } = React

you can just do

import React, { Component } from 'react'

without any errors telling you that React has no default export.