Sonar cli fails on adding allowImportingTsExtensions in tsconfig.json

sonar fails on adding allowImportingTsExtensions in tsconfig.json. it skips all ts file for scanning.

log: (due to project guidelines cannot paste complete log in here) but below is the sample

INFO: Creating TypeScript program
NFO: TypeScript configuration file /builds/automation/tsconfig.json
INFO: 209 source files to be analyzed
ERROR: Error: Unknown compiler option ‘allowImportingTsExtensions’.

and sonar fails to scan all src ts files

Hi,

Welcome back.

What’s your SonarQube version?

 
Ann

HI,

its Developer Edition - Version 10.0 (build 68432)

1 Like

Hi,

Thanks for the update. I’ve flagged this for the language experts.

 
Ann

Thanks Ann,

Do we have any workaround for now ?

Hi,

this happens because we don’t yet support TypeScript 5. We should release it in a couple of days. If you need a workaround urgently, you could create another tsconfig file without this option, which would be used only for analysis.

Hi,

Thanks for the inputs. Creating separate tsconfig is for sonar not an option for us currently!

may be I will wait for the Sonar release, Could you please let me know when it will be released?

Thanks,
Sri

Hi Sri,

At the bottom of this page you can sign up to get notifications of new SQ releases.

 
HTH,
Ann

1 Like

Hello . Can you please help with this approach ? How should I configure SonarQube to use that second file ?

hi @Davit_Sargsyan ,

use the sonar.typescript.tsconfigPaths property, either in the config or the UI

2 Likes

@saberduck I’m adding this configuration to my sonar-project.properties . But it doesn’t work anyway

sonar.typescript.tsConfigPath=./tsconfig.sonar.json
sonar.typescript.tsConfigPath=tsconfig.sonar.json
sonar.typescript.tsConfigPaths=tsconfig.sonar.json
sonar.typescript.tsConfigPaths=./tsconfig.sonar.json

could you please share debug logs?

sure . please see attached . Seems like it still keeps reference to the original tsconfig.json file

INFO: 1167 source files to be analyzed

ERROR: Error: Unknown compiler option ‘allowImportingTsExtensions’.

ERROR: Failed to create program: Unknown compiler option ‘allowImportingTsExtensions’.
INFO: Creating TypeScript program (done) | time=82ms
INFO: Skipped 1167 file(s) because they were not part of any tsconfig (enable debug logs to see the full list)
INFO: 1167/1167 source files have been analyzed

Hi,

Could you please provide the full, verbose log? This guide will help you find them.

 
Thx,
Ann

@Davit_Sargsyan is there a chance you are using an old version of SonarQube?

The compiler option allowImportingTsExtensions was introduced in TypeScript 5.

TypeScript 5 has been supported since SonarQube 10.1 and SonarCloud at the same time, since June 2023.

You can see the docs for language support.

@ganncamp @gab thanks for your replies . I’ve resolved the problem with creating second tsconfig file . But now I’m facing to another issue . For some reasons SonarQube doesn’t see my coverage/lcov.info file

and here’s my conf file line for path

sonar.javascript.lcov.reportPaths=coverage/lcov.info

Hi,

I’m glad you worked through your initial problem. LCov is a new question & it deserves its own thread.

 
:smiley:
Ann