Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array.isArray does not recognize readonly arrays #1793

Closed
GauBen opened this issue Aug 29, 2024 · 2 comments
Closed

Array.isArray does not recognize readonly arrays #1793

GauBen opened this issue Aug 29, 2024 · 2 comments

Comments

@GauBen
Copy link

GauBen commented Aug 29, 2024

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

@orta
Copy link
Contributor

orta commented Aug 29, 2024

This is the wrong repo (this is for the DOM types) but you're looking at an incredibly deep rabbit hole if you want to try solve that, you can start based on links in one of my best attempts a few years back: microsoft/TypeScript#42316

@GauBen
Copy link
Author

GauBen commented Aug 30, 2024

Thanks for the heads up! It was an interesting read but I'm not sure I should invest some more time in this. I'm closing in favor of microsoft/TypeScript#17002

@GauBen GauBen closed this as completed Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants