typescriptvisual-studio-2015typescript1.5typescript1.7

Compilation of projects with different Typescript versions in Visual Studio 2015


VS2015-SP2. In one solution there are two typescript projects, one has version 1.5, the other 1.7. Which compiler will be used for the solution?


Solution

  • You can actually test this.

    I have TypeScript versions 1.7 and 1.5 installed. This means that the following folder contains two subfolders named 1.5 and 1.7:

    C:\Program Files (x86)\Microsoft SDKs\TypeScript

    I created a simple solution with two projects.

    One of the projects has TypeScript version 1.5:

    <TypeScriptToolsVersion>1.5</TypeScriptToolsVersion>
    

    The other one has TypeScript version 1.7:

    <TypeScriptToolsVersion>1.7</TypeScriptToolsVersion>
    

    Now if you open the Developer Command Prompt for VS2015, navigate to the folder of your sln file and issue the following command, you can actually see which compiler will be invoked.

    msbuild DifferentTypeScriptVersions.sln
    

    My output contains these telling lines:

    PreComputeCompileTypeScript:
    C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.7\tsc.exe  --sourcemap --target ES5 --noEmitOnError COMPUTE_PATHS_ONLY "Z:\SomewhereOnMyDrive\DifferentTypeScriptVersions\TypeScriptProjectWithOnePointSeven\app.ts"
    .......
    PreComputeCompileTypeScript:
    C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.5\tsc.exe  --sourcemap --target ES5 --noEmitOnError COMPUTE_PATHS_ONLY "Z:\SomewhereOnMyDrive\DifferentTypeScriptVersions\TypeScriptProjectWithOnePointFive\app.ts"
    

    As you can see each project invokes the correct version.

    Last remark: I tested the same thing with only 1.7 installed. Of course that way both projects were compiled with 1.7.

    Update: If you want to be sure that VS uses the same logic, you can do that as well.

    Go to Tools/Options/Projects and Solutions/Build and Run and set the MSBuild project build output verbosity to Normal.

    Now if you rebuild the solution, in the Output pane you'll be able to see information about which compiler is getting invoked. I tested it and it used 1.5 for the project with 1.5 setting and 1.7 for the project with 1.7 setting.