Typescript Projects in TFS

If you develop Typescript applications in projects using TFS as source code control, you need to take precautions to build or publish your web application.

As the .ts and .js files are related in a VS project (.csproj) in the form

<TypeScriptCompile Include="Scripts\Index.ts" />
<Content Include="Scripts\Index.js">

when you check-out the .ts file, the .js is automatically checked out. The DependentUpon clause is also responsible for displaying the two files as parent-child nodes in Solution Explorer.

However if you build and the .ts file has not been checked out, the Typescript compiler is unable to generate the .js file, as it is set read-only in the file system.

I know of two solutions to this problem:

The first (and probably simpler one) is to include the .ts file in TFS, but NOT the .js file. This is achieved by adding the .ts (and automatically, the .js) file in TFS, but reverting the Add operation for the .js file.

The other solution is similar to the one I sketched about 3 years ago, namely to run tf checkout before and tf checkin after invoking tsc.

By the way, you can ignore the .d.ts (definition) files in this scenario, as they do not generate .js files.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.