SonarJS
SonarJS copied to clipboard
Create rule: Assertions comparing incompatible types should not be made
RSPEC-5845 Expected issues This is part of MMF-2213
One needs to be careful when reporting the textual representation of a type inferred by TypeScript's compiler. For example, TypeScript would return { a: A, ..., z: Z }[]
for the expression [{ a: A(), ..., z: Z() }]
while object[]
not only is shorter but also more meaningful from JavaScript developer's perspective. In that regard, we need to normalise the types before reporting them. To do so, one can take inspiration from function-return-type, extract that piece of code into a reusable helper function, and eventually extend it.
I created draft PR #2848 , which is unfinished. We currently don't support type resolution in the new test framework. I decided to postpone this rule for later.