tsconfig.json in TypeScript

  • Just like anyother language which has its own folder structure to store it own types of files, TypeScript too does have it
  • We manage all the different types of file in each folder example “src” folder has all the .ts files and “public” folder has all the .html files
  • All this folder names are manages inside tsconfig.json file, below command creates the tsconfig.json file.
  • You can read all about the tsconfig.json file at https://www.staging-typescript.org/tsconfig
--command to create tsconfig.json file
tsc --init

We modify below lines in tsconfig.json to create an appropriate folder structure :

All the src files i.e .ts files inside /src folder

"rootDir": "./src"
--Anything outside src folder should not compiled hence below include
--add below line at the end
"include": [src]

All the output .js files should be placed inside /public folder

"outDir": "./public"

Reference for tsconfig.json

https://www.staging-typescript.org/tsconfig

Leave a Comment