Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the TypeScript Tools version set in an ASP.NET 5 Project?

I'm working with a default ASP.NET 5 Web project template and trying to determine how to dictate the TypeScript tools and ultimately compiler version for my application.

I'm not yet using Gulp so this post's answer does not seem to hold water. The reason being, my app even without Gulp has to be told which TypeScript compiler to use. This answer as well wasn't about finding the version but rather using features not yet supported.

In VSNET 2013, the TypeScript tools version and compiler targeted was set in the project's properties:

<TypeScriptToolsVersion>1.7</TypeScriptToolsVersion>

I believe it to be an option of the compilerOptions section of my tsconfig.json file. However I get no intellisense for version and it appears the documentation is sparse. This link states it just emits the compiler's version but doesn't allow specifying it.

I currently have version 1.6 and 1.7 installed on my machine. If there is a need for me to dictate a specific compiler version, how do I set that in an ASP.NET 5 web template? Again the answer isn't immediately to use Gulp because it builds and compiles my .ts files as is now, so something is dictating the compiler being used.

like image 269
atconway Avatar asked Mar 01 '16 05:03

atconway


People also ask

How can I tell what version of TypeScript is on my project?

The -g means it's installed on your system globally so that the TypeScript compiler can be used in any of your projects. Test that the TypeScript is installed correctly by typing tsc -v into your terminal or command prompt. You should see the TypeScript version print out to the screen.

How do I find TypeScript version in Visual Studio?

If you only have TypeScript installed for Visual Studio then: Start the Visual Studio Command Prompt. Type tsc -v and hit Enter.


2 Answers

It appears the TypeScript Tools (and corresponding compiler version) for ASP.NET 5 projects is set in the following files:

TS 1.7: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TypeScript\Microsoft.TypeScript.targets

<PropertyGroup>
    <TypeScriptToolsVersion Condition="'$(TypeScriptToolsVersion)'==''">1.7</TypeScriptToolsVersion>
    <TscToolPath Condition="'$(TscToolPath)' == ''">$(MSBuildProgramFiles32)\Microsoft SDKs\TypeScript</TscToolPath>
    <TscToolExe Condition="'$(TscToolExe)' == ''">tsc.exe</TscToolExe>
    <TscYieldDuringToolExecution Condition="'$(TscYieldDuringToolExecution)' == ''">true</TscYieldDuringToolExecution>
</PropertyGroup>

TS 1.8 C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\TypeScript

<PropertyGroup>
    <TypeScriptToolsVersion Condition="'$(TypeScriptToolsVersion)'==''">1.8</TypeScriptToolsVersion>
    <!-- Check the default folder for the nuget version of the installer first, if that exists we should use that. -->
    <TscToolPath Condition="'$(TscToolPath)' == '' AND Exists('$(MSBuildThisFileDirectory)tsc\tsc.exe') ">$(MSBuildThisFileDirectory)tsc\</TscToolPath>
    <TscToolPath Condition="'$(TscToolPath)' == ''">$(MSBuildProgramFiles32)\Microsoft SDKs\TypeScript</TscToolPath>
    <TscToolExe Condition="'$(TscToolExe)' == ''">tsc.exe</TscToolExe>
    <TscYieldDuringToolExecution Condition="'$(TscYieldDuringToolExecution)' == ''">true</TscYieldDuringToolExecution>
</PropertyGroup>

Notice the 1st line in the configuration above has the value 1.7 for the TypeScript 1.7 compiler.

like image 91
atconway Avatar answered Nov 06 '22 03:11

atconway


Visual Studio 2015 IDE will use TypeScript that is specified in PATH. If you can change it from TypeScript 1.7 to 1.8, it will work with ASP.NET 5 apps and other apps as will.

Don't need to use GULP, I hope your using VS IDE or its VS Code

This approach will force all other applications to use TypeScript 1.8 only, however non ASP.NET 5 apps have entry in proj files.

like image 26
Mithun Pattankar Avatar answered Nov 06 '22 03:11

Mithun Pattankar