Hi,
I’m trying to add this rule that exist in Javascript rule, to my code that runs in Typescript.
I want to solve this issue:
const items: number[] = [1,2,3,4];
items.filter((item) => values.includes(item));
const values: number[] = [1,2];
Hi,
I’m trying to add this rule that exist in Javascript rule, to my code that runs in Typescript.
I want to solve this issue:
const items: number[] = [1,2,3,4];
items.filter((item) => values.includes(item));
const values: number[] = [1,2];
Hello @elin,
Thank you for your feedback. The rule is indeed only active for JavaScript at the moment. I will check why it is not available for TypeScript and come back to you.
Best,
Ilia
Thank you for your response,
Waiting to hear from you Ilia,
Best Regards,
Eli.
Hey @elin,
We haven’t activated this rule for TypeScript because the TypeScript compiler already checks for this kind of issue ts(2304), so flagging it would be redundant.
Hi Ilia,
Thanks for the help,
I have tried it out,
The error is being thrown at run time.
Can you please advise if this error can be caught before runtime?
Thanks, Eli.
Hey Ilia,
I don’t think this scenario is covered:
const arr = [1,2,3,4];
const res = arr.map(item => invalidData.includes(item));
const invalidData = [1,2];
can you please check if there is some role for it?
Thanks,
Eli.
Hey @elin,
I confirm that this case is not caught by the TS type checker, and throws an error at runtime.
I have therefore opened an issue in our analyzer.