Is sonarjs support flow type?

// @flow strict
// ...

class Abc extends PureComponent<{}, StateType> {
  _width: number;
  _width = 0;

I received the follow error

Rename or remove duplicate property name ‘_width’.

Is it a false positive ?

Hello @eltonlauhk01,

SonarCloud supports flow syntax. Can you please provide more explanations? It’s not clear to me where the error comes from. Which rule is triggering this issue? Why do you think it’s a false positive? I am not an expert in flow, however, afaik sample code is indeed declaring two fields with the same name.

If you think that this is a false positive, then the best way forward would be to prepare a small reproducer project on github and analyze it on SonarCloud.

1 Like

Thanks @saberduck

After some study, we found that the issue was due to wrong implementation of setting type and initial value for the class property variables.

The correct way should be do it in one go, as shown in below testing project

I think we can set a case close here, thanks

cc @eltonlauhk01

1 Like