TypeScript : Emit Error: Write to file failed..

categories: [ Visual Studio ] [ VSTS / TFS ] tags: [ TFS ] [ TFS Build ] [ TypeScript ]
created: 15 Nov 2013 @ 09:30 modified: 15 Nov 2013 @ 09:30

I have been playing around with TypeScript for a while and usually I just publish from my machine Embarrassed smile but today I decided to setup a CI build for the solution and found that I received the error

 <Path to file>.ts (1): Emit Error: Write to file failed..

When a build agent checks out code for building the primary source files are locked so obviously it wouldn't let me overwrite any as part of my build process.

It took me a couple of minutes to realize it but this error was basically due to me having checked in the .js and .jsmap file that is generated for .ts files when you build a TypeScript enabled project. Simple enough to fix:

1. Remove all .js and .jsmap files that are generated off .ts files from your project

2. Make sure those same files are deleted from source control

3. Kick off the build and smile because things should be running smoothly again Smile