我有兴趣在我使用Visual Studio 2013开发的Web应用程序中使用ECMAScript 6功能.目前语法似乎不起作用,如何配置VS使其工作?
我想知道是否有办法在Visual Studio中为项目设置特定的TypeScript编译器版本.因此,我可以将项目配置为始终使用版本1.0,即使将发布新版本.
我知道以前是不可能的,我想知道在TypeScript成熟到1.0版之后情况是否会发生变化.
我注意到现在Visual Studio <TypeScriptToolsVersion>0.9</TypeScriptToolsVersion>在项目文件中创建属性,但找不到任何有关它的文档.
我有打字稿1.5.3和视觉工作室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 />
Run Code Online (Sandbox Code Playgroud)
模块:
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, ' '));
}
Run Code Online (Sandbox Code Playgroud)