Visual Studio 2012 TypeScript项目在编译期间忽略两个文件

时间:2012-10-23 23:20:51

标签: typescript


   我有一个Visual Studio 2012 TypeScript项目。当我第一次创建项目时,我添加了两个新的.ts文件,这些文件是Framework.ts& Graphics.ts。我最近添加了两个TypeScript文件作为声明文件,并将它们命名为.d.ts,例如Framework.d.ts和Graphics.d.ts。有趣的是,所有这4个文件都将Build Action属性设置为TypeScriptCompile,但其中只有2个构建(Framework.ts和Graphics.ts),其他.d.ts文件仍然具有关于a的原始.js构建代码形状模块。我想也许.d.ts扩展名存在问题,并将这些文件重命名为Framework_d.ts和Graphics_d.ts。这也没有构建它们!

此时我不知所措。我查看了csproj文件:

<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" />

然后是typescript编译器的execute命令:

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

这真的应该构建这些文件。我只是不知道它为什么拒绝。有谁知道如何解决这个问题?

2 个答案:

答案 0 :(得分:2)

如果他们如你所说,声明文件,那么他们将没有javascript输出。我认为您不需要将这些“添加”到项目中,或者至少不要在它们上应用TypeScriptCompile构建操作。您可以使用

将它们包含在其他源文件中
///<reference path="Framework\Framework.d.ts" 
///<reference path="Graphics.d.ts" 

所以他们看到了声明。

答案 1 :(得分:0)

我不确定这是你的情况, 但是有一些与.ts文件编码有关的问题。

不幸的是,TypeScript无法使用签名编译UTF-8 。 您可以选择另一个保存选项 “文件” - &gt;“高级保存选项” - &gt;选择“UTF-8无签名”。

检查当前问题。 http://typescript.codeplex.com/workitem/85

由于