Open
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have searched for related issues and found none that matched my issue.
- I have read the FAQ and my problem is not listed.
Playground Link
Repro Code
declare const test1: (t: number) => void;
declare const test2: <T extends number>(t: T) => void;
// fails correctly
test1(1 as any);
// should fail
test2(1 as any);
ESLint Config
module.exports = {
parser: "@typescript-eslint/parser",
rules: {
"@typescript-eslint/no-unsafe-argument": "error"
},
};
tsconfig
Expected Result
I expect all use-cases to be consistent and report this as an error.
Actual Result
The use-cases with a type constraint doesn't report this as an error.
Additional Info
This seems similar to #10314, and it looks like the fix should be similar.
I'll add that I see similar inconsistencies on no-unsafe-assignment
and no-unsafe-return
(false positives, in which the rule reports unnecessarily):
// no-unsafe-return
declare const test1: (callback: () => unknown) => void;
declare const test2: <T>(callback: () => T) => void;
declare const test3: <T extends unknown>(callback: () => T) => void;
// passes correctly
test1(() => 1 as any);
// should pass
test2(() => 1 as any);
// should pass
test3(() => 1 as any);
// no-unsafe-assignment
declare const test4: (t: { t: unknown }) => void;
declare const test5: <T extends unknown>(t: { t: T }) => void;
// pass correctly
test4({ t: 1 as any });
// should pass
test5({ t: 1 as any });
I'll be happy also to report them (separately or as part of this issue) if this makes sense.