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 incorrect type guard #44745

Closed
JakeCoxon opened this issue Jun 25, 2021 · 3 comments
Closed

Array.IsArray incorrect type guard #44745

JakeCoxon opened this issue Jun 25, 2021 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@JakeCoxon
Copy link

Bug Report

πŸ”Ž Search Terms

Array isArray unknown any type guard

πŸ•— Version & Regression Information

3.3.3 - 4.3.4

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about type guard

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

const x: unknown = ['asdasd']

if (Array.isArray(x)) {
    x[0] - 123123
}

πŸ™ Actual behavior

It passes type checking

πŸ™‚ Expected behavior

I would expect it to fail because although x is an array, x[0] should still be unknown. I'd expect to be forced to check the type of the items

@MartinJohns
Copy link
Contributor

Duplicate of #44703 / #41808. Search terms: Array.isArray in:title

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jun 25, 2021
@JakeCoxon
Copy link
Author

^ I saw that issue but it is very vague and I couldn't work out if it is the same problem

@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants