TypeScript files not analyzed in new project

Hi,

I recently setup SonarCloud for the first time using the default configuration for automatic analysis from GitHub.

The problem that I am now facing is that TypeScript files (ts & tsx) which make up the majority of the codebase are not being analyzed by SonarCloud. Other files such as regular JavaScript are being detected without issues and according to this docs article TypeScript should also be supported for automatic analysis.

I have already tried recreating the project. The online project configuration also looks like it should analyze these files.

Thanks in advance!

Hey there.

Can you let us know how the tsconfig.json file is configured for this project? Feel free to paste it here.

As the repository is a monorepo containing multiple sub-projects there is no tsconfig in the root directory (could that be the problem?).

Following is the tsconfig for one of the apps located in a subdirectory:

{
  "extends": "@organization/config/ts/nextjs.json",
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      ...
    }
  },
  "include": ["**/*.ts", "**/*.tsx", "next-env.d.ts"],
  "exclude": ["node_modules/", "cypress/"]
}

Each project has its own tsconfig.
Let me know if the inherited compilerOptions are relevant.

Hi Colin, are there any updates on this?
Also, I’m not sure if you saw my reply.

Hi Felix,

We are taking a look at the logs on SonarCloud and get back to you.
Did you have a look at this page regarding importing monorepos on SonarCloud?

Best,
Ilia

After you pointed me there, I tried following these instructions but was quickly confused as the setup process for every project asked me to completely override the sonar config file in the repo’s root. While the one sub-project I set up successfully now also includes SQL files, TS files are still missing.

I also tried pointing to one of my nested tsconfigs but without success.

What in the end solved this problem for me (or just serves as a workaround) was adding a tsconfig.json to the root of my monorepo which includes all ts and tsx files:

{
  "include": ["**/*.ts", "**/*.tsx"]
}

Having another solution to this problem would of course be great but for now this works. Might also be that this is an intentional design design.

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