This is my starter tsconfig that I use for React / TypeScript applications. See further down the gist for a version without comments.
{
"compilerOptions": {
// source code will be kept in this location
"baseUrl": "./src",
// allows possible commonjs imports to be used inside an ES module context
"esModuleInterop": true,
// disallow inconsistently-cased references to the same file.
"forceConsistentCasingInFileNames": true,
// support JSX in TSX files
"jsx": "react",
// allow next-gen JS in source code
"module": "esnext",
// helps TS recognize Node-style imports
"moduleResolution": "node",
// prevent use of any type
"noImplicitAny": true,
// require return types
"noImplicitReturns": true,
// use the relative path @components/* for importing components into files
// can add more relative paths here as needed
"paths": {
"@components/*": ["components/*"],
},
// include modules imported with .json extension
"resolveJsonModule": true,
// enable all strict type checking options
"strict": true,
// compile to ESNext
// this should be bumped down as needed (likely down to ES5 for larger, less experimental apps)
"target": "esnext",
}
}
Without comments:
{
"compilerOptions": {
"baseUrl": "./src",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"module": "esnext",
"moduleResolution": "node",
"noImplicitAny": true,
"noImplicitReturns": true,
"paths": {
"@components/*": ["components/*"],
},
"resolveJsonModule": true,
"strict": true,
"target": "esnext",
}
}