Closed
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have searched for related issues and found none that matched my issue.
- I have read the FAQ and my problem is not listed.
Playground Link
Repro Code
let a: string | undefined
let b: { message: string } | undefined
const t = (t: string) => t
const foo = a
? a
: b
? b.message
: t("global.error.unknown")
The error happens when running the Fix
on this rule: It breaks the code.
ESLint Config
module.exports = {
parser: "@typescript-eslint/parser",
rules: {
"@typescript-eslint/prefer-nullish-coalescing": "error",
},
};
tsconfig
Expected Result
let a: string | undefined
let b: { message: string } | undefined
const t = (t: string) => t
const foo = a ?? (b
? b.message
: t("global.error.unknown"))
Actual Result
let a: string | undefined
let b: { message: string } | undefined
const t = (t: string) => t
const foo = a ?? b
? b.message
: t("global.error.unknown")
Additional Info
No response