TypeScript: useUnknownInCatchVariables compiler option causes main branch to show up empty

In one of our projects on sonarcloud.io, we explicitly set the useUnknownInCatchVariables typescript compiler option to false as it is enabled by default in strict mode in TS 4.4 (see their release announcement).

With this, the scanner reports

 ERROR: Unknown compiler option 'useUnknownInCatchVariables'.

during analysis. For pull requests, the results still seem fine, but on the main branch, SonarCloud just says The main branch has no lines of code. This looks very similar to this thread I found in the archive where another typescript compiler option caused similar behavior.

It would be great if you could support the new flag / make sure it doesn’t break the analysis. Thanks!

1 Like

Yep getting the same issue here. Would be nice to be able to set the Typescript version rather than just use whatever is built-in. I am using the Docker image so I’m only able to use whatever it comes with rather than whatever version is defined in my package.json (in this case it’s 4.4.2)

Running into this as well after upgrading to Typescript 4.4. Any workaround?

Hi,

we don’t support TS 4.4 yet, it will happen in the next release, which should happen in ~3 weeks.

Here is a ticket to track it https://github.com/SonarSource/SonarJS/issues/2802

Unfortunately the only workaround is to create another tsconfig file without the option, which is used only for analysis and set via sonar.typescript.tsconfigPath property in sonar-project.properties file.

1 Like

Thanks a lot for the workaround hint, works fine for us.
Looking forward to the next Sonar release :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.