Closed as duplicate of#10722
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 function useLoaderData<T = any>(): T;
const { foo } = useLoaderData() as { foo: string };
ESLint Config
{
"rules": {
"@typescript-eslint/no-unnecessary-type-assertion": "error",
}
}
tsconfig
Expected Result
No error.
Actual Result
False positive.
Additional Info
I use useLoaderData
from the react-router
package.
I could rewrite the code like this:
declare function useLoaderData<T = any>(): T;
const { foo } = useLoaderData<{ foo: string }>();
But this is functionally equivalent, and I think the rule shouldn't error in this case.