Bug: [no-unnecessary-condition] should not say that falsey bigint is truthy #10197
Closed
4 tasks done
Labels
accepting prs
Go ahead, send a pull request that resolves this issue
bug
Something isn't working
good first issue
Good for newcomers
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
Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://typescript-eslint.io/play/#ts=5.6.3&fileType=.tsx&code=CYUwxgNghgTiAEYD2A7AzgF3gMyhNIAngEICWA5gJIoYBc8ADCgNwBQp28AFLvkWVRoBKeAG9WAXyA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tiacTJTIAhtEK0yHJgBNK%2BSpPRQA7iKaRwYAL4hNQA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false
Repro Code
ESLint Config
tsconfig
Expected Result
Unnecessary conditional, value is always falsy.
Actual Result
Unnecessary conditional, value is always truthy.
Additional Info
This is a bug with this line.
typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts
Line 32 in 373c63a
The
.value
field returns aPseudoBigInt
object that looks like{ negative?: boolean, base10Value: string }
, rather than abigint
itself (for legacy TS support reasons). So checking for truthiness is incorrect; we need to convert to a real bigint.The text was updated successfully, but these errors were encountered: