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

11,315

Solution 1

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.

Solution 2

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.

Solution 3

If you have the warning in Visual Studio:

Warning Your project does not specify a TypeScriptToolsVersion. The latest available TypeScript compiler will be used (x.y). To remove this warning, set TypeScriptToolsVersion to a specific version or "Latest" to always select the latest compiler.

You can edit TypeScript Tools Version in your projects properties. You get this warning if you have the value for TypeScript version set to "None specified". Set it to "Use latest available" and the warning will go away.

enter image description here

Share:
11,315
atconway
Author by

atconway

I am a Practice Lead Consultant designing and building applications in web and .NET and surrounding technologies with a concentration in the following: JavaScript/TypeScript/Angular/React, C#/VB.NET, ASP.NET Core/MVC, Web API/WCF, EF, and SQL Server placing an emphasis on OOP, Architecture, and Design. I thoroughly enjoy web and Microsoft development technologies and have been a proponent of their languages and platforms since I began work as an engineer 20+ years ago.

Updated on July 19, 2022

Comments

  • atconway
    atconway almost 2 years

    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.

  • atconway
    atconway about 8 years
    Yes I'm familiar with what is in the PATH variable for TypeScript. Is there any easy way to prove this works? (i.e. see some output during build of the targeted TS compiler path based on the modifications to the PATH variable, etc?)
  • Mithun Pattankar
    Mithun Pattankar about 8 years
    it worked with Angular 2 Beta releases as my VS 2015 was having TS 1.5 when i installed it for first time.
  • atconway
    atconway about 8 years
    In Windows 8 and older versions of TS the path variable was used (see my blog post: allenconway.net/2015/07/which-version-of-typescript-is.html) However, I checked and on Windows 10 with TS 1.8 there is no value defined in the PATH variable to the TS compiler. Are you sure about your answer?
  • Jason H
    Jason H over 7 years
    Install the latest version helps too :)
  • Imme Pak
    Imme Pak about 7 years
    Unfortunately there is no straight dependency on PATH and compiler version used by VS. In my case PATH contains way to 1.0 version, VS used 1.8 version and I need 2.1. So, my investigation going on
  • Aluan Haddad
    Aluan Haddad about 7 years
    This isn't an answer. It's also full of extraneous information. You would just disable TypeScript compilation in VS and you'd be fine. Client-side is not server side. This has even less to do with gulp I'm nothing at all to do with vs code