7

I'm installing ts-loader to work with webpack.

Does someone know how to choose which typescript version to use ?

No matter what I do, I always get a message saying

ts-loader: Using typescript@1.8.10 and /app/tsconfig.json

I intend to use typescript@2 but I have no clue how to tell ts-loader to use the proper version...

Thanks

aherve
  • 3,795
  • 6
  • 28
  • 41
  • 1
    Add typescript@2 to your devDependencies. ts-loader should it use without any configuration. If you don't, it'll use globally installed typescript. – goenning Nov 25 '16 at 14:15

2 Answers2

1

Unfortunately your answer is not sufficient for those who use react-scripts-ts or any other dependencies which require the older version of the typescript. I have added to my package dependency typescript ^2.6.2, but ts-loader still shows typescript 2.5.3, because "react-scripts-ts" has a dependency "typescript":"~2.5.3", so somehow that dependency takes precedence.

The actual solution that I found is creating npm-shrinkwrap.json file where I override subdependency of react-scripts-ts to the correct dependency, something like this:

{
    "dependencies":
    {
        "react-scripts-ts":
        {
            "dependencies":{
                "typescript": { "version": "2.6.2" }
            }
        }
    }
}

After creating this file, I remove folder node_modules and execute npm install

If you're not sure which package in your dependency tree depends on specific version of some package, you can find it in package-lock.json file

Philipp Munin
  • 5,610
  • 7
  • 37
  • 60
0

Ok, found it

It turns out typescript was installed by npm as a dependency. And by default it's 1.8

Adding typescript@2 to package.json properly set the typescript version

aherve
  • 3,795
  • 6
  • 28
  • 41