𝗛𝗼𝘄 𝘁𝗼 𝗖𝗼𝗻𝗳𝗶𝗴𝘂𝗿𝗲 𝘁𝘀𝗰𝗼𝗻𝗳𝗶𝗴.𝗷𝘀𝗼𝗻
The tsconfig.json file controls your TypeScript project. It tells the compiler how to build your code. Run tsc --init to create one.
Use these core options:
- target: Sets the JS version.
- module: Sets how modules work.
- strict: Turns on type checks.
- outDir: Where compiled files go.
- rootDir: Where source files live.
Set strict to true. This catches bugs early. Adding it later is hard. Start strict on day one.
Use rootDir for your source folder. Use outDir for your build folder. This keeps your project clean.
Add include and exclude lists. These tell TypeScript which files to read.
Path aliases stop long relative paths. Use short names like @utils.
Turn on sourceMap. This connects compiled JS to your TS code. It makes debugging easy.
Recommended settings:
- Target: ES2022
- Strict: true
- OutDir: ./dist
- RootDir: ./src
Source: https://dev.to/krunalkanojiya/how-to-configure-tsconfigjson-for-your-typescript-project-3d0k