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


Comment by Andy P

Thanks - newbie to TypeScript and TFS here, I was really confused by this, your explanation sorted it nicely.

Andy P
Comment by unsafecode

What about if I need to deploy those .js and .map files along with .ts?

We're in a SharePoint 2013 solution, and all static files are deployed to a document library with a module. So all three files need to be under source control in order to allow them to be properly copied.

Of course, I'm getting this error, but only if we set the workspace as server.

Any tips? Would be glad to hear any, I'm struggling with this issue at the moment, since it makes building the solution harder (TS compilation fails).

Comment by unsafecode

OK, I actually found you can have those files included in solution (and SP modules) while not having them under source control