Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Tsconfig Cheatsheet

This is just a cheatsheet of the most common options I need. For full documentation refer to docs such as this.

Create Template Config File

You can create a generic tsconfig.json file with a lot of options commented out so you can easily see what you can enable, by running:

tsc --init

Compile On Save

To configure compilation on saving a file, add the compileOnSave option like so:

{
    "compileOnSave": true,
    "compilerOptions": {
}

This works in Netbeans after installing the typescript plugin.

Change Output Directory

By default, tsc files will be compiled into the same directory. To compile out to a different directory such as a /js or /dest folder add the outDir option like so:

{
    "compilerOptions": {
        "outDir": "../../public/js"
    }
}

Remove Comments

If you don't want to output the comments (which is probably a pretty good idea), then add removeComments option like so:

{
    "compilerOptions": {
        "removeComments": true
    }
}

References

Last updated: 10th November 2021
First published: 30th March 2020