3
votes


I have a Visual Studio 2012 TypeScript project. When I first made the project I added 2 new .ts files these were Framework.ts & Graphics.ts. I recently added two more TypeScript files to be declaration files and named them .d.ts such as Framework.d.ts and Graphics.d.ts. The interesting part is that all 4 of these files have the Build Action Property set to TypeScriptCompile yet only 2 of them build (Framework.ts and Graphics.ts) the other .d.ts files still have the original .js build code regarding a shapes module. I thought perhaps there was a problem with the .d.ts extension and renamed these files to Framework_d.ts and Graphics_d.ts. This didn't build them either!

At this point I am at a loss. I looked at the csproj file:

<TypeScriptCompile Include="Framework\Framework.d.ts" />
<Content Include="Framework\Framework.d.js">
  <DependentUpon>Framework.d.ts</DependentUpon>
</Content>
<Content Include="Graphics\Graphics.d.js">
  <DependentUpon>Graphics.d.ts</DependentUpon>
</Content>
<Content Include="TestPages\SpriteBatch.html" />
<TypeScriptCompile Include="Framework\Framework.ts" />
<Content Include="Framework\Framework.js">
  <DependentUpon>Framework.ts</DependentUpon>
</Content>
<Content Include="Graphics\Graphics.js">
  <DependentUpon>Graphics.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="Graphics\Graphics.d.ts" />
<TypeScriptCompile Include="Graphics\Graphics.ts" />

And then the execute command for the typescript compiler:

<Target Name="BeforeBuild">
  <Exec Command="&quot;$(PROGRAMFILES)\Microsoft SDKs\TypeScript\0.8.0.0\tsc&quot; @(TypeScriptCompile ->'&quot;%(fullpath)&quot;', ' ')" />
</Target>

This really should build these files too. I just have no idea why it refuses to. Does anyone know how to fix this?

2

2 Answers

2
votes

If they are as you say, declaration files, then they will have no javascript output. I think you do not need to 'add' these to the project or at the very least, do not bother applying the TypeScriptCompile build action on them. You can just include them in the other source files using

///<reference path="Framework\Framework.d.ts" 
///<reference path="Graphics.d.ts" 

so they see the declarations.

0
votes

I'm not sure this is your case or not, but there are some issues regarding with .ts file encoding.

Unfortunately TypeScript cannot compile UTF-8 with signature. You might choose another save option by "FILE"-->"Advanced Save Options"--> Select "UTF-8 without signature".

Check current issue. http://typescript.codeplex.com/workitem/85

Thanks