I wonder if there's a way to set specific TypeScript compiler version for project in Visual Studio. So I could configure a project to always use version 1.0, even if new versions would be released.
I know it was not possible before and I wonder if things changes after TypeScript matured to 1.0 version.
I noticed that now Visual Studio creates <TypeScriptToolsVersion>0.9</TypeScriptToolsVersion>
property in a project file, but couldn't find any documentation about it.
Tip: To get a specific TypeScript version, specify @version during npm install. For example, for TypeScript 3.6. 0, you would use npm install --save-dev [email protected] . To preview the next version of TypeScript, run npm install --save-dev typescript@next .
If you try to compile a project with <TypeScriptToolsVersion>0.9</TypeScriptToolsVersion>
using TypeScript version 1.0 you'll get the following error:
Your project file uses a different version of the TypeScript compiler and tools than is currently installed on this machine. No compiler was found at C:\Program Files (x86)\Microsoft SDKs\TypeScript\0.9\tsc.exe. You may be able to fix this problem by changing the element in your project file.
So it's preventing you from compiling with newer version. It does not however put the compiler into some 0.9 compatibility mode.
But if you have TypeScript 0.9 installed, it will compile against that version. So yes, you can force a specific version of the TypeScript compiler using the attribute.
Basically what the <TypeScriptToolsVersion>
do is that it changes the path to the compiler:
C:\Program Files (x86)\Microsoft SDKs\TypeScript\<TypeScriptToolsVersion>\tsc.exe
I have solved it by adding $(TypeScriptToolsVersion)\
after TypeScript\
in the condition statement.
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets"
Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\$(TypeScriptToolsVersion)\Microsoft.TypeScript.targets')" />
Visual Studio Version -> VS2013
<PropertyGroup> ...... <IISExpressUseClassicPipelineMode /> <TypeScriptToolsVersion>1.8</TypeScriptToolsVersion> </PropertyGroup>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With