Wrong version of Typescript found by SonarScanner

I’m using SonarCloud and SonarScanner - version below:
INFO: SonarScanner 4.4.0.2170
INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
INFO: Linux 4.14.193-113.317.amzn1.x86_64 amd64
INFO: SONAR_SCANNER_OPTS=-server

with JavaScript/TypeScript Code Quality and Security 6.5.0.13383

My project is setup to use TypeScript 3.6.5, apart from having that version in my package.json file, typescript 3.6.5 is also installed globally in my system.

When I run the scanner I see the following message: “INFO: Version of TypeScript used during analysis: 3.8.3”

Because SonarScanner is running on 3.8.3, it’s detecting things I added for 3.6.5 as “unnecessary assertion”.
Why can’t I run the scanner with 3.6.5?

Thanks

Hello Guilherme,

Thank you for your message, and welcome to our community!

Unfortunately, you cannot run the scanner with a TypeScript version of your choice. The reason is that SonarJS packages its own version of TypeScript (3.8.3) that is used during analysis, and does not consider any other version that may lie in your file system.

Hope this answers your question,

Yassin

1 Like