Home > Software engineering >  TSConfig - Output ".js" File Generated Relative to each ".ts" file
TSConfig - Output ".js" File Generated Relative to each ".ts" file

Time:09-15

I have a non-standard application with the following file structure

project
├── tsconfig.json
├── app_1
│   ├── ts
│   └── js
|
└── app_2
    ├── ts
    └── js

I would like for files inside of the ts folder to be compiled and placed in its corresponding app's js folder (eg. compiled files for .ts files found in app_1/ts should be placed in app_1/js).

Currently, I'm using VSCode to compile my files and place them in their corresponding folders. However, I dont know how to structure my TSConfig file to allow me to do what I described. Can anybody help me with this. I've been trying to use the outDir property, but haven't had any luck.

CodePudding user response:

The easiest approach is probably to create 2 different tsconfig files (one in app_1 and another one in app_2) and specify the appropriate outDir option for each.

Note that you can keep a root tsconfig file and have the 2 others inherit from the root using extends. If both apps share the same config, it avoids duplicating all the TS config.

  • Related