TS: Interface dynamic property names cause a false-positive report of RSPEC-4335

In typescript, creating an intersection with an interface that contains a dynamic property name emits RSPEC-4335 violation: “Types without members, ‘any’ and ‘never’ should not be used in type intersections”.

  • SonarLint version: v1.19.0
  • Example
const propName = 'prop-name';

interface MyInterface {
  [propName]: string;
}

interface MyOtherInterface {
  prop: string;
}

type MyType = MyOtherInterface & MyInterface;

Hello @amrsalama!

Welcome to SonarSource community.

There is indeed a bug in the implementation of the rule. I created a ticket to address this issue as soon as possible.

Thank you for reporting us this false positive.

Cheers,
Yassin

1 Like

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