Skip to content

Array.isArray does not recognize readonly arrays #1793

@GauBen

Description

@GauBen

Hi TS team! I'm having an issue with the type of Array.isArray:

declare const x: readonly number[]

if (Array.isArray(x)) {
    let y = x[0]
     // ^? let y: any
}

Playground

I'm willing to open a PR if the fix is as I suggest in the playground above

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions