Typescript file produces a false positive 'already defined' when types and variable share same name

Using SonarCloud with Typescript, I observe the following behaviour: when in a file I have a declared type which have the same name as a function, Sonar detects an ‘already defined’ pattern.

Reproducer

export type MyService = ReturnType<typeof MyService>
export function MyService() {
  return {
    sayHi: (name: string) => {
      return `Hello ${name}!`
    }
  }
}

In this example, SonarCloud incorrectly reports:
'MyService' is already defined.

Expected behaviour

Such a naming should not cause issues as the Typescript compiler knows when it uses the type and when it uses the variable/function name.

Hi @giovannini,

Welcome to the community! Thank you for bringing this up.

You are right this is indeed a False Positive.

I created a ticket on Github, you can follow it to get updates:

Cheers,
Gabriel