Bug: [no-unnecessary-type-assertion] false positive when casting changes the inferred type from a generic #5359
Labels
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=4.7.2&sourceType=module&code=CYUwxgNghgTiAEYD2A7AzgF3gMyUgXPADwAqANPAKoB8AFAG5QQCuIhlAlPALzXwkBYAFDCA9KIDmIFCBgBLMGniwEKJAHd4clNllxgypURTMAtgCNZFTPJQS6jFm3g3tErr3gmLs4cnRY5rA8OHi0AEThXFBK3pYw8OJ6SDCEagC0zCgyYCBoaLAAnukYhQAOIOkxaLIYcqhAA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tiacTJTIAhtEK0ipWkOTJE0fJQ5N0UOdA7RI4MAF8QOoA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA
Repro Code
ESLint Config
tsconfig
Expected Result
no error
Actual Result
error: no-unnecessary-type-assertion
Additional Info
sometimes it's useful to use a cast instead of specifying the generic, in case you only want to have to specify one type while still having the other types inferred.
Versions
@typescript-eslint/eslint-plugin
5.30.7
@typescript-eslint/parser
5.30.7
TypeScript
4.7.2
ESLint
8.15.0
The text was updated successfully, but these errors were encountered: