Error about unsupported TS version while project is using supported version

We have a similar problem where we have started getting the error

‘You are using version of TypeScript 2.6.2 which is not supported; supported versions >=3.2.1’.

Our package.json shows typescript version as “typescript”: “~3.2.4” so I’m not sure what the problem is. I have searched our entire project and cannot see any reference to 2.6.2.

Our build is running on an Azure DevOps hosted build agent so the TypeScript version installed there is somewhat out of our control

Can you check node_modules/typescript/package.json in your project? what’s version there?

Apologies for the delay. Since the time of my original question, we now have “~3.5.3” in our project’s package.json. The same version is also in node_modules/typescript/package.json that you asked be checked.

The error is still visible in the build logs

##[error]ERROR: You are using version of TypeScript 2.6.2 which is not supported; supported versions >=3.2.1

This doesn’t appear to be having any obvious negative side effects as the analysis is still getting run and updated. It would be nice to clear the error however.

We are also seeing this in our Azure Pipelines build output.

ERROR: You are using version of TypeScript 2.9.2 which is not supported; supported versions >=3.2.1

We are targeting ^3.0.0 in our project json and resolving to 3.7.3 in node_modules.

I can see from the logs it is picking up a version of typescript in a transitive dependency. Is there any way to correct this behaviour and use the top level typescript dependency?

@ojpbay, @brett.postin,

Could you share full (debug, with -X option) logs?

There is something fishy here, when analyzer is seeing old version of TS it should not even continue, I don’t get how you are getting any results.
To get the version of TypeScript we rely on standard dependency resolution, with require("typescript"), so it’s weird how we are getting the version not installed in your project.

Are you sure to install your dependencies before running the analysis?

Which version of SonarJS are you using on your SonarQube instance (or is it SonarCloud)?

@Lena the only relevant “typescript” logs I can see are the following:

 2020-01-24T11:15:37.8032873Z 11:15:37.427 DEBUG: Looking for TypeScript recursively in D:\a\1\s
2020-01-24T11:15:37.8824610Z 11:15:37.880 INFO: Using TypeScript at: 'D:\a\1\s\App\node_modules\@[REDACTED]\ui-tools\node_modules'

The main project references (“typescript”: “^3.0.0”) and 3.7.3 is in the root node_modules. The redacted dependency references (“typescript”: “^2.0.0”) and 2.9.2 is in the sub node_modules folder and the one detected.

Yarn install is run before Sonarcloud analysis is setup and run.

If these aren’t the full logs or you want additional logs please let me know how to set the relevant options via the Azure DevOps tasks and how I can send these privately.

Ok, now I see what’s happening. We trying to find TypeScript location and happen to find the wrong one (transitive) first.

I created a ticket to fix this problem.
As a workaround you can try dropping D:\a\1\s\App\node_modules\@[REDACTED]\ui-tools\node_modules\typescript before the analysis. That way analyzer will find the direct TypeScript dependency with 3.7.3 version.

Thanks for the feedback!

Hi Lena, I am seeing same error. It was working fine before. Error seems to be occurring after i have updated the plugin version for JavaScript. from 5.x to 6.x.

ERROR: You are using version of TypeScript 2.6.2 which is not supported; supported versions >=3.2.1
ERROR: If it’s not possible to upgrade version of TypeScript used by the project, consider installing supported TypeScript version just for the time of analysis
ERROR: Failure during analysis, Node.js command to start eslint-bridge was: {NODE_PATH=/web/tpc_repos/product-system-api/node_modules} node /web/tpc_repos/product-system-api/.scannerwork/.sonartmp/eslint-bridge-bundle/package/bin/server 43777

Hi @upendar

Which version of TS do you actually use? We had to bump the requirement for min TS version. So if you are using 2.6.2 it’s ok that after migration to 6.x analysis failed. If your project is using newer version and you have transitive dependency to 2.6.2. (like in the thread above), it should be fixed with the next release ( and you can check the workarounds I suggested already.

Can’t speak for others but we are currently using ~3.5.3.

Look forward to the fix in the upcoming release!

Many thanks.

Please ignore. I was using one of the old repos for my POC which had Type script V 2.6.2. I picked the latest one which is having “typescript”: “3.5.3”. this error is gone.

A post was split to a new topic: Global Typescript is used instead of local