Visual Studio TypeScript选项

MBe*_*ius 18 visual-studio-2012 typescript

如何告诉TypeScript编译器从Visual Studio中生成amd模块(--module amd).

谢谢.

moh*_*azy 9

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.

  • @MortenMertner - 现在他们又把它删除了.现在不想让这个太容易了,不是吗? (8认同)
  • 看起来他们已经添加了一个选项来配置它,无论是在TS 0.8.1中还是作为Web Essentials的一部分.打开工具 - >选项,然后在Web Essentials-> TypeScript下查看. (2认同)

小智 8

在最新的Visual Studio 2013 Update 3 + WebEssentials上,现在(最终)在项目选项窗格中正确移动选项(右键单击项目 - >选项 - > TypeScript构建窗格).


Ole*_*nko 5

即使对于TS 1.0和Web 2013年VS 2013 Update 3的WebEssentials,这个问题仍然存在,请在此处查看此解决方案:http://icanmakethiswork.blogspot.com/2014/02/typescript-and-requirejs-keep-it-simple.html或者很快:

1)打开项目文件.

2)找到这一行:

  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')" />
Run Code Online (Sandbox Code Playgroud)

3)在此之前插入以下行:

    <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
    <TypeScriptModuleKind>amd</TypeScriptModuleKind>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)' == 'Release'">
    <TypeScriptModuleKind>amd</TypeScriptModuleKind>
  </PropertyGroup>
Run Code Online (Sandbox Code Playgroud)