Typescript project on SonarCloud doesn't recognize lines of code?

Template for a good new topic, formatted with Markdown:

  • ALM used (GitHub, Bitbucket Cloud, Azure DevOps)
    Github
  • CI system used (Bitbucket Cloud, Azure DevOps, Travis CI, Circle CI
    CircleCI
  • Scanner command used when applicable (private details masked)
    Used SonarClouds built in integration with Github private repo
  • Languages of the repository
    Typescript, Javascript
  • Only if the SonarCloud project is public, the URL
    • And if you need help with pull request decoration, then the URL to the PR too
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
    When I push the typescript project using the command line sonar-scanner to our SonarCloud account, it correctly identifies all the Typescript file as “lines of code”, but when I integrated the exact same project to our Github account, it recognized only the Javascript files as “lines of code” and the rest of the Typescript as simply “lines” (and so no analysis was done) (will attach pic)
  • Steps to reproduce
    Integrate Typescript project using SonarCloud’s Github integration?
  • Potential workaround
    Manually push from the command line or create a new build step to automate this.

Screen Shot 2020-02-06 at 11.31.02 AM

Hello @Scott_Justason,

Could you navigate to Administration > Background Tasks on the project page on SonarCloud and give me the ID of a background task that did not pick-up the TypeScript files?

Thanks,
Tom

Just a suggestion, since I have personally been dealing with typescript issues, is that sonarcloud uses the typescript dependency in your projects node_modules folder. It is very likely that this dependency is not actually installed during your Github CI but is when you scan it on your PC from the CLI. This means sonarcloud will not analyze typescript in your project on Github. If you run npm install on your project during your CI run before analysis that will solve the problem, if this is indeed what is actually going wrong here.

Hi Tom,

Here is an ID AXAWOm7oQclT7Ra-u5d7. Basically its any of them because none of the Typescript files are ever picked up.

Thanks,
Scott

Hi Tim,

I have another project integrated in the same way (to the Github repo directly), with no CI involved on either. That other project does pick up the Typescript files correctly, so I wonder if something went wrong during the initial integration. I read some posts about the same thing you’re suggesting, but I think with the direct Github integration it just needs a package.json that has Typescript as a dependency… at least it works with the other project.

Thanks