Skip to content

💅 Actually used private field considered unused (via ??=) #6994

@jaens

Description

@jaens

Environment information

(see playground)

Rule name

lint/correctness/noUnusedPrivateClassMembers

Playground link

https://biomejs.dev/playground/?analyzerFixMode=safeAndUnsafeFixes&code=ZQB4AHAAbwByAHQAIABjAGwAYQBzAHMAIABUAGUAcwB0ACAAewAKACAAIABwAHIAaQB2AGEAdABlACAAZgBpAGUAbABkADoAIABuAHUAbQBiAGUAcgA7AAoACgAgACAAYwBvAG4AcwB0AHIAdQBjAHQAbwByACgAKQAgAHsACgAgACAAIAAgAHQAaABpAHMALgBmAGkAZQBsAGQAIAA%2FAD8APQAgADEAOwAKACAAIAB9AAoAfQA%3D&ruleDomains.react=recommended&ruleDomains.test=recommended&ruleDomains.next=recommended&ruleDomains.project=recommended

Expected result

  • field should not be considered unused here.
  • Fixing should not delete the field.
export class Test {
  private field: number;

  constructor() {
    this.field ??= 1;
  }
}

(this is reduced, the original was more complicated, in particular there was a side effect on the right-hand of ??= ...)

Related

Looks like the private variable check has more issues: #6974, #6933

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LinterArea: linterL-JavaScriptLanguage: JavaScript and super languagesS-Bug-confirmedStatus: report has been confirmed as a valid bug

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions