Typescript: tsc --version shows 1.5.3 after upgrade to 1.6?

Created on 25 Sep 2015  路  19Comments  路  Source: microsoft/TypeScript

Hello,

I have upgraded typescript to the latest 1.6 release by downloading the VS 2015 installation here: http://www.typescriptlang.org/#Download

However if I open up command prompt and do tsc --version I get 1.5.3

image

The reason I am suspecting this may be a problem is because when I have a tsconfig.json in my project:

{
  "compilerOptions": {
    "module": "AMD",
    "target": "ES5",   
    "noImplicitAny": true,
    "removeComments": true,
    "preserveConstEnums": true,
    "sourceMap": true,
    "listFiles": true,
    "noEmitOnError": true,
    "outDir": "../wwwroot/dist",
      "outFile": "tscompiled.js"
  },
  "files": [
    "app.ts"
  ]
}

and this is the file

/// <reference path="../typings/tsd.d.ts" />
/// <reference path="../typings/es6.d.ts" />
/// <reference path="../typings/core-js.d.ts" />
import {Router} from "aurelia-router";

// my comment!
module Dazinator {
    export class App {
        constructor() {
            this.message = "Welcome To Daz's World ya!"
        }
        message: string;
    }
}

When I build the VS solution, I get an empty 'tscompiled.js' file produce - with a source mapping directive:

//# sourceMappingURL=tscompiled.js.map

If I do a compile form the command line it says it doesn't recognise the outFile argument

![image](https://cloud.githubusercontent.com/assets/3176632/10107159/19dbf5be-63b1-11e5-8ecc-c72709ecb3c9.png)

Looking at the docs - it says outFile is to be used as out is deprecated: https://github.com/Microsoft/TypeScript/wiki/Compiler-Options

Any help would be appreciated!

Bug Visual Studio

Most helpful comment

there are two issues here:

  1. path set to C:\program files (x86)\Microsoft SDKs\TypeScript\1.0 if you ever installed TypeScript 1.0, and not removed by further versions. the variable should be in your System Variables, and not in User Variables as shown in the above screenshot. Best way to find out is to use where tsc from a command prompt.
  2. in VS command prompet, you always have the path pointing to C:\program files (x86)\Microsoft SDKs\TypeScript\1.5 even after updating to 1.6. this environment variable is set in C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat, edit the file manually to replace:
@rem Add path to TypeScript Compiler
@if exist "%ProgramFiles%\Microsoft SDKs\TypeScript\1.5" set PATH=%ProgramFiles%\Microsoft SDKs\TypeScript\1.5;%PATH%
@if exist "%ProgramFiles(x86)%\Microsoft SDKs\TypeScript\1.5" set PATH=%ProgramFiles(x86)%\Microsoft SDKs\TypeScript\1.5;%PATH%

to

@rem Add path to TypeScript Compiler
@if exist "%ProgramFiles%\Microsoft SDKs\TypeScript\1.6" set PATH=%ProgramFiles%\Microsoft SDKs\TypeScript\1.6;%PATH%
@if exist "%ProgramFiles(x86)%\Microsoft SDKs\TypeScript\1.6" set PATH=%ProgramFiles(x86)%\Microsoft SDKs\TypeScript\1.6;%PATH%

This issue is tracking 2, for 1 please refer to #2068.

hope that helps.

All 19 comments

Doh - this is probably my stupidity.. I am new to modules!

I am assuming the reason I am getting an empty file is because I am exporting a module - which basically means that the javascript for that module is loaded separately from a distinct js file at runtime and is therefore excluded from the out file that ts is producing - is that correct?

@dazinator Sort of. The target of --out (or --outFile) will get all globally scoped JavaScript in your project. Since your file above is a module (due to the import) that .ts file gets its own .js and then there's no other globally scoped JavaScript to put in your --out target file. We have an issue tracking making it an error when this occurs (an empty file from --out) since it's essentially always the error you've made and confuses people.

@dazinator the reason you are getting 1.5.3 after your TypeScript install is probably that your Visual Studio TypeScript installation has shadowed your npm directory. To fix it you probably need to change your PATH variable. To figure out where things are, open up CMD and type in where tsc

@danquirk - thank you for clarifying this for me :-)
@DanielRosenwasser - I will give that a try, cheers!

@DanielRosenwasser - this is the result of the where tsc from within a VS (developer) command prompt:

image

If I do ts where from an ordinary command prompt it resolved to the npm install of tsc so this does seem to be the VS environment shadowing the path.

I don't understand though - shouldn't the installer for typescript (vs tools) 1.6 have updated it appropriately?

image

I tried doing a repair also and that hasn't corrected the issue.

image

I think that's a symptom of #2068.

The problem is the path is set as part of installing vs and not intalling typescript; obviously that does not work for updates. This is not the same as https://github.com/Microsoft/TypeScript/issues/2068 which we used to do in the 1.0 time but not since.

@paulvanbrenk is touching this area now, so hopefully we get a fix in next release.

work around just change environment path to new version
capture4

@alyahmedaly I don't have an entry in my PATH at all for Typescript. Can try adding one.. but it seems like VS is shadowing the path somehow anyway but will try!

there are two issues here:

  1. path set to C:\program files (x86)\Microsoft SDKs\TypeScript\1.0 if you ever installed TypeScript 1.0, and not removed by further versions. the variable should be in your System Variables, and not in User Variables as shown in the above screenshot. Best way to find out is to use where tsc from a command prompt.
  2. in VS command prompet, you always have the path pointing to C:\program files (x86)\Microsoft SDKs\TypeScript\1.5 even after updating to 1.6. this environment variable is set in C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat, edit the file manually to replace:
@rem Add path to TypeScript Compiler
@if exist "%ProgramFiles%\Microsoft SDKs\TypeScript\1.5" set PATH=%ProgramFiles%\Microsoft SDKs\TypeScript\1.5;%PATH%
@if exist "%ProgramFiles(x86)%\Microsoft SDKs\TypeScript\1.5" set PATH=%ProgramFiles(x86)%\Microsoft SDKs\TypeScript\1.5;%PATH%

to

@rem Add path to TypeScript Compiler
@if exist "%ProgramFiles%\Microsoft SDKs\TypeScript\1.6" set PATH=%ProgramFiles%\Microsoft SDKs\TypeScript\1.6;%PATH%
@if exist "%ProgramFiles(x86)%\Microsoft SDKs\TypeScript\1.6" set PATH=%ProgramFiles(x86)%\Microsoft SDKs\TypeScript\1.6;%PATH%

This issue is tracking 2, for 1 please refer to #2068.

hope that helps.

Yeah _2_ is the relevant issue for me. Thanks for the workaround!

Note: Adding it to the %PATH% environment variable is not sufficient. Since C:Program Files (x86)Microsoft Visual Studio 12.0Common7ToolsVsDevCmd.bat will override this when using the developer command prompt compared to regular cmd prompt. Manually Editing the file is essentially breaking support for patches when installing a patch. (If i am not mistaken, the file will not be overwritten for any new changes within the next update, unless there is a custom action within the installer which overrides the modified time stamp of the file). The change also needs to be present within visual studio installer as well.

Another option for issue 2 outlined by @mhegazy a few posts ago is to simply remove/comment the lines in question in VsDevCmd.bat. Note: this is NOT a good approach if you don't install typescript via npm. However, if you have installed typescript globally via "npm install typescript -g", removing/commenting the lines in question will allow the typescript path to resolve to your global node modules location.

Now when you run "tsc -v" it will report the same version from both the VS command prompt and non-VS command prompt.

@paulvanbrenk any fixes applicable for this due to the codenamed thing?

You mean low impact installer? No, that won't help much here.. I do think I have a solution, which I'll get in for 2.1

Did this make the 2.1 milestone in the end, just wondering if it should be closed or not!

It did not

This path is set by vsdevcmd\ext\typescript.bat which is invoked indirectly by VsDevCmd.bat. After upgrading from 2.5 to 2.7 using the TypeScript SDK installer, the 2.5 path was left intact. I worked around the issue by updating this file.

The snippet that I used in typescript.bat is:

@echo [TEST:%~nx0] Checking for tsc...
where tsc > NUL 2>&1
if "%ERRORLEVEL%" EQU "0" (
    @echo [INFO:%~nx0] Existing tsc found
    goto end
)

It is based on the preexisting :test block. I put it near the top, right above the lines that check for the SDK-based installation of the TypeScript path.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kimamula picture kimamula  路  147Comments

sandersn picture sandersn  路  265Comments

OliverJAsh picture OliverJAsh  路  242Comments

disshishkov picture disshishkov  路  224Comments

jonathandturner picture jonathandturner  路  147Comments