Bug: [no-unnecessary-type-assertion] false positive for string literals #10723
Labels
bug
Something isn't working
locked due to age
Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
triage
Waiting for team members to take a look
Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://typescript-eslint.io/play/#ts=5.7.3&fileType=.tsx&code=MYewdgzgLgBAtgTwHIFc4CMCmAnGBeGAJgFYBYAKFEljgEMAPfGATgAYKKroYAHHYTGFgEABgBIA3gAoAsrSgALAHRwAlmCmJUGHABp4DAJSGYAehgBGVqwC%2BAUhExaEGOIlg0WbPZEBuIA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tiacTJTIAhtEK0ipWkOTJE0fJQ5N0UOdA7RI4MAF8QeoA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false
Repro Code
ESLint Config
tsconfig
Expected Result
There should be no error in the provided playground
Actual Result
There’s an error in line 4:
Additional Info
Without the type assertion,
percent
would just be inferred asstring
, but we want it to be${number}%
.While it’s true that
as const
would give us the correct inference here, as${number}%
should be allowed, too.The text was updated successfully, but these errors were encountered: