我有一个Visual Studio 2012 TypeScript项目。当我第一次创建该项目时,我添加了2个新的.ts文件,分别为Framework.ts & Graphics.ts。最近我又添加了两个TypeScript文件用于声明,并将它们命名为.d.ts,例如Framework.d.ts和Graphics.d.ts。有趣的是,这4个文件的所有构建操作均设置为TypeScriptCompile,但只有其中2个(Framework.ts和Graphics.ts)可以被编译,而其他的.d.ts文件仍然具有原始的.js构建代码,涉及到一个shapes模块。我认为可能是.d.ts扩展名存在问题,于是将这些文件重命名为Framework_d.ts和Graphics_d.ts,但也无法进行编译!
到现在为止,我感到很困惑。我查看了csproj文件:
到现在为止,我感到很困惑。我查看了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 编译器的执行命令:
<Target Name="BeforeBuild">
<Exec Command=""$(PROGRAMFILES)\Microsoft SDKs\TypeScript\0.8.0.0\tsc" @(TypeScriptCompile ->'"%(fullpath)"', ' ')" />
</Target>
我真的希望它也能构建这些文件。只是我不知道为什么它拒绝了。有人知道如何解决吗?
import Framework = module("Framework");
那么我会得到一个错误,因为 require() 函数不存在。因为生成的 js 中的行是 var Framework = require("Framework"); 我是否遗漏了一些关于 require 的东西? - IanelGreenleaf