Skip to content

Array.prototype.at not type guarded #50119

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

Closed
qwelias opened this issue Jul 31, 2022 · 2 comments
Closed

Array.prototype.at not type guarded #50119

qwelias opened this issue Jul 31, 2022 · 2 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@qwelias
Copy link

qwelias commented Jul 31, 2022

Bug Report

πŸ”Ž Search Terms

array at type guard

πŸ•— Version & Regression Information

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

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

const arr: Array<{}> = []
let obj: {}

if (arr[0]) {
    obj = arr[0]
    obj = arr.at(0) // error
}

πŸ™ Actual behavior

arr.at(0) returns {} | undefined

πŸ™‚ Expected behavior

arr.at(0) returns {} because arr[0] returns {}

@whzx5byb
Copy link

whzx5byb commented Aug 1, 2022

See #45551

@DanielRosenwasser DanielRosenwasser added the Working as Intended The behavior described is the intended behavior; this is not a bug label Aug 1, 2022
@typescript-bot
Copy link
Collaborator

This issue has been marked 'Working as Intended' 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
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

4 participants