Skip to content

Shouldn't Array.isArray narrow the type to unknown[]? #43865

Closed
@Faithfinder

Description

@Faithfinder

lib Update Request

Configuration Check

My compilation target is whatever and my lib is the default.

Missing / Incorrect Definition

Array.isArray()

Sample Code

function parseUnknown(value: unknown): Whatever {
  if (Array.isArray(value) {
    // value is suddenly `any[]` even though I've only confirmed that it's an array
  }
}

I might be missing other usecases, but seems like Array.isArray typing should be smarter than just is any[]

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