Bug: [no-unnecessary-type-assertion] false positive on type narrowing #11242
Labels
bug
Something isn't working
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
working as intended
Issues that are closed as they are working as intended
Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://typescript-eslint.io/play/#ts=5.8.3&fileType=.tsx&code=C4TwDgpgBAYgdlAvFA3gWAFBSgHgEpQQAewEcAJgM5SXABOAlnAOZQA%2BUArhRAGZMRyAPgAUASgBcUPAG5MAX0wBjAPZxaUYFPhIo4pEK49%2BcQXIyZe3JcAZqoAGxWUIAeToAZZxHFTajFnYoOE4AWwAjCDpUTGwGXj0AWQBDYAALADo6ZIoVUP0hZAAGDIBWMRisbCg6CGBOOgRgfWTqfyZmc2x5QgcXSuqauoam8S6oRQxJoA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tiacTJTIAhtEK0ipWkOTJE0fJQ5N0UOdA7RI4MAF8QOoA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eFYDArugDTg10NM8AOXapUAYQAW6aAGsylDul4BfECqA&tokens=false
Repro Code
ESLint Config
tsconfig
Expected Result
I expected that
as string
would be allowed, since TypeScript fails without it.Actual Result
no-unnecessary-type-assertion claims the
as string
is unnecessaryAdditional Info
This is similar to #11054, but I do not know if it has the same root cause.
The text was updated successfully, but these errors were encountered: