Bug: [no-unnecessary-condition] False positives for branded strings #7293
Labels
accepting prs
Go ahead, send a pull request that resolves this issue
bug
Something isn't working
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://typescript-eslint.io/play#ts=5.1.6&fileType=.tsx&code=C4TwDgpgBAsiBCAnAhgOwCYXQZWIglqgOZQC8UAznoSQGRQDeUA%2BswEYoYBcUArqgGtUAewDuqKAF8A3AFgAUAoDGw1FSgc0mHNWJkoAIgNRkFWAk7bcBYnPn4AZlAAUmjFms0AlIwVQoAPQBUAAiwpTCALYQwAAWNAB0CpIKCkFQACrxZujCEGYiwFAANhDI6FDA4cglhMAQiFANiMKISfIqakWIEES8xciInnrkRiZmVDZEdo4uPX0DQ7pEPgx%2BgcFhEdFxiclAA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tiacTJTIAhtEK0yHJgBNK%2BSpPRRE0aB2iRwYAL4gtQA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false
Repro Code
ESLint Config
tsconfig
Expected Result
I did not expect to get a linter error, since
brandedString
in the example can be falsy.Actual Result
The rule reports:
This looks like a false positive to me, because
string & { }
does not disallow empty strings or the like.Additional Info
#2506 could be somewhat related, since they also had issues with a similar intersection.
The text was updated successfully, but these errors were encountered: