除非提供了“--module”标志,否则无法编译模块

时间:2015-08-28 14:29:57

标签: typescript visual-studio-2015 typescript1.5

我有打字稿1.5.3和visual studio 2015。

我在我的打字稿中使用外部模块,但由于以下错误而无法构建: “构建:除非提供'--module'标志,否则无法编译模块。”

打字稿设置:

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Any CPU'">
<TypeScriptTarget>ES5</TypeScriptTarget>
<TypeScriptCompileOnSaveEnabled>True</TypeScriptCompileOnSaveEnabled>
<TypeScriptNoImplicitAny>False</TypeScriptNoImplicitAny>
<TypeScriptModuleKind>AMD</TypeScriptModuleKind>
<TypeScriptRemoveComments>False</TypeScriptRemoveComments>
<TypeScriptOutFile />
<TypeScriptOutDir />
<TypeScriptGeneratesDeclarations>False</TypeScriptGeneratesDeclarations>
<TypeScriptNoEmitOnError>True</TypeScriptNoEmitOnError>
<TypeScriptSourceMap>True</TypeScriptSourceMap>
<TypeScriptMapRoot />
<TypeScriptSourceRoot />

模块:

export class Functions {
errorHelper(xhr: any, errorType: any, exception?: any) {
    var errorMessage = exception || xhr.statusText;
    alert(`Account lookup failed. ${errorMessage}`);
}

getParameterByName(name: string) {
    name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
    var regex = new RegExp(`[\?&]${name}=([^&#]*)`);
    var results = regex.exec(location.search);
    return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}

1 个答案:

答案 0 :(得分:5)

在Stackoverflow上查看post。 VS2015 RTM中存在一个错误。您必须编辑csproj文件才能解决该问题。

  

修复:

     
      
  1. 右键单击项目,将其卸载,然后再次右键单击并进行编辑。
  2.   
  3. 搜索<TypeScriptModuleKind>,然后找到父元素,该元素应称为<PropertyGroup>
  4.   
  5. Any CPU属性值中查找“Condition”文字,将其更改为“AnyCPU” - 即删除空格。
  6.   
  7. 再次搜索并重复更改,以防其他构建条件具有TypeScript设置。
  8.   
相关问题