Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to specify typescript version to ts-loader?

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 [email protected] 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

like image 321
aherve Avatar asked Nov 25 '16 14:11

aherve


1 Answers

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

like image 52
Philipp Munin Avatar answered Sep 22 '22 03:09

Philipp Munin