Closed
Description
Looks like the fix for #529 did not cover all edge cases.
{
"rules": {
"@typescript-eslint/no-unnecessary-type-assertion": "error",
}
}
const optionalNonNull = (s?: string) => { };
let s: string | null | undefined;
/*
Argument of type 'string | null | undefined' is not assignable to parameter of type 'string | undefined'.
Type 'null' is not assignable to type 'string | undefined'.
*/
optionalNonNull(s);
/*
This assertion is unnecessary since the receiver accepts the original type of the expression.
*/
optionalNonNull(s!);
Expected Result
Should not trigger an error.
Actual Result
Triggers an error.
Additional Info
N/A
Versions
"@typescript-eslint/eslint-plugin": "^2.3.3",
Also tested with master 054df27