Problem:
You add TypeScript file to an existing Visual Studio web project, but when you build the project, the TypeScript files do not generate equivalent JavaScript file.
Assumptions:
- you have installed the TypeScript plugin for Visual Studio 2012/2013
- when you right-click on the TypeScript file and select Properties, the BuildAction is set to be TypeScripCompile.
Solution:
In Visual Studio 2012: in order to use TypeScript files in an existing ASP.NET Web project, you need to make a manual change to the project file.
you need to:
1. right click on the project, select Unload Project.
1. right click on the project, select Edit.
Scroll down the XML file, to the end tag:
just before the end tag, insert this XML:
note: if you want to use newer JavaScript features such as properties, then you need ECMAScript 5 support (and a newer browser such as IE9 and up), and so you need to replace ES3 with ES5 in the above text.
This resolves this compile error:
Accessors are only available when targeting ECMAScript 5 and higher.
Save your changes.
Right-click on the project, select Reload Project.
Build the project.
The TypeScript files should now compile OK, and output equivalent JavaScript files.
You add TypeScript file to an existing Visual Studio web project, but when you build the project, the TypeScript files do not generate equivalent JavaScript file.
Assumptions:
- you have installed the TypeScript plugin for Visual Studio 2012/2013
- when you right-click on the TypeScript file and select Properties, the BuildAction is set to be TypeScripCompile.
Solution:
In Visual Studio 2012: in order to use TypeScript files in an existing ASP.NET Web project, you need to make a manual change to the project file.
you need to:
1. right click on the project, select Unload Project.
1. right click on the project, select Edit.
Scroll down the XML file, to the end tag:
</Project>
just before the end tag, insert this XML:
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<TypeScriptTarget>ES3</TypeScriptTarget>
<TypeScriptRemoveComments>false</TypeScriptRemoveComments>
<TypeScriptSourceMap>true</TypeScriptSourceMap>
<TypeScriptModuleKind>AMD</TypeScriptModuleKind>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<TypeScriptTarget>ES3</TypeScriptTarget>
<TypeScriptRemoveComments>true</TypeScriptRemoveComments>
<TypeScriptSourceMap>false</TypeScriptSourceMap>
<TypeScriptModuleKind>AMD</TypeScriptModuleKind>
</PropertyGroup>
<Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" />
</Project>
note: if you want to use newer JavaScript features such as properties, then you need ECMAScript 5 support (and a newer browser such as IE9 and up), and so you need to replace ES3 with ES5 in the above text.
This resolves this compile error:
Accessors are only available when targeting ECMAScript 5 and higher.
Save your changes.
Right-click on the project, select Reload Project.
Build the project.
The TypeScript files should now compile OK, and output equivalent JavaScript files.
Comments
Post a Comment