Skip to content

Incorrect Report that an Object may be null #43537

Closed
@legodude17

Description

@legodude17

Bug Report

🔎 Search Terms

  • Object is possibly 'null'
  • undefined

🕗 Version & Regression Information

This is the behavior in every version I tried, and I reviewed the FAQ for entries about unexpected warnings about possible 'null's and 'undefined's.

I tried versions 3.3.3333 and 4.3.0-beta, though I did not try any in the middle.

⏯ Playground Link

Playground link with relevant code

💻 Code

const refs: {current: {value: number} | null}[] = [{current: { value: 2}}];

if (refs.every((ref) => ref.current != null)) {
    refs[0].current.value = 1;
}

🙁 Actual behavior

"Object is possibly 'null'" warning on refs[0].current

🙂 Expected behavior

No warnings, as they cannot be null since the refs.every(...) is checking that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions