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

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch