Question

I've been working with TypeScript and MVC4 today. Everything is working well but every time I add a new .ts file using VS's 'Add / TypeScript File' dialog the file that is added is populated with some sample code:

 // Interface
interface IPoint {
getDist(): number;
}

// Module
module Shapes {

.... etc.

Where's this sample code coming from? I want my files to be empty. I don't want to have to rip this code out every time I add a file.

Was it helpful?

Solution

You'll need to edit the template, which you can find here...

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\msfz1qy5.oca\~IC\IT\CSharp\1033\f.zip

The file named file.ts contains the item template for TypeScript new files.

OTHER TIPS

Steve Fenton's answer above is correct, however with TypeScript 0.8.3 I had to use the Windows Search function to find f.zip - it's now in three locations, at least for me:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript\~IC\IT\CSharp\1033\f.zip
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript\IT\CSharp\1033\f.zip
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\VWDExpressExtensions\TypeScript\IT\CSharp\1033\f.zip

Only after changing all of the above did TypeScript files appear with the proper template.

Would be nice if Microsoft included an option for changing the default; it's not nice having to remove a bunch of unnecessary code every time I want to add a file - which is especially irritating when setting up a project, which can involve creating upwards of 100 source files in a complex directory tree. Googling around finally led me to this post.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top