Visual Studio TypeScript 选项
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12710691/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visual Studio TypeScript Options
提问by MBeckius
How do I tell the TypeScript compiler to generate amd modules (--module amd) from within Visual Studio.
我如何告诉 TypeScript 编译器从 Visual Studio 中生成 amd 模块(--module amd)。
Thanks.
谢谢。
采纳答案by mohamed hegazy
In your project file you will need to change the MSBuild target that is building TypeScript files. If you are using the default template for "HTML Application built with TypeScript", unload your project, edit the project file, you will find a target called "BeforeBuild" that is calling the compiler at "$(PROGRAMFILES)\Microsoft SDKs\TypeScript\0.8.0.0\tsc", add --module amd to it; save and reload your project. next time you build you should see the command argument passed correctly to the compiler.
在您的项目文件中,您需要更改正在构建 TypeScript 文件的 MSBuild 目标。如果您使用“使用 TypeScript 构建的 HTML 应用程序”的默认模板,请卸载您的项目,编辑项目文件,您将在“$(PROGRAMFILES)\Microsoft SDKs\TypeScript”中找到一个名为“BeforeBuild”的目标正在调用编译器\0.8.0.0\tsc", 添加 --module amd ; 保存并重新加载您的项目。下次构建时,您应该会看到命令参数正确传递给编译器。
回答by MadLux
On the latest Visual Studio 2013 Update 3 + WebEssentials the options are now (finally) properly moved in the Project Options Pane (Right click on the project -> Options -> TypeScript Build pane).
在最新的 Visual Studio 2013 Update 3 + WebEssentials 上,选项现在(最终)在项目选项窗格中正确移动(右键单击项目 -> 选项 -> TypeScript 构建窗格)。
回答by Oleksandr Papchenko
Becouse this problem is still actual even for TS 1.0 and WebEssentials for VS 2013 Update 3, check this solution here: http://icanmakethiswork.blogspot.com/2014/02/typescript-and-requirejs-keep-it-simple.htmlOr shortly:
因为即使对于 TS 1.0 和 WebEssentials for VS 2013 Update 3,这个问题仍然存在,请在此处查看此解决方案:http://icanmakethiswork.blogspot.com/2014/02/typescript-and-requirejs-keep-it-simple.html或很快:
1) Open project file.
1) 打开项目文件。
2) find this lines:
2)找到这一行:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')" />
3)Insert this lines before:
3)在此之前插入此行:
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<TypeScriptModuleKind>amd</TypeScriptModuleKind>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<TypeScriptModuleKind>amd</TypeScriptModuleKind>
</PropertyGroup>

