Wednesday, September 13, 2017

Configuring Typescript in Visual Studio 2017

Be aware that there are 2 places to configure Typescript behavior in Visual Studio 2017 (and older, I assume).  They do not communicate with each other.  The first is the tsconfig.json file at the root of your project (the one you get when you type tsc --init in the command line).  The second is in the properties of your project (right-click the project folder in Solution Explorer => Properties => Typescript Build).

If you find your Typescript behaving in a way that is different from what you expect, make sure that both config files are synced.

For instance, despite my explicitly putting'compileOnSave':false in tsconfig.json,  javascript files kept popping in next to my .ts files at every save.  It was because Compile on save was checked in the project properties.

The More You Know!