We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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 at type guard
Playground link with relevant code
const arr: Array<{}> = [] let obj: {} if (arr[0]) { obj = arr[0] obj = arr.at(0) // error }
arr.at(0) returns {} | undefined
arr.at(0)
{} | undefined
arr.at(0) returns {} because arr[0] returns {}
{}
arr[0]
The text was updated successfully, but these errors were encountered:
See #45551
Sorry, something went wrong.
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes.
No branches or pull requests
Bug Report
π Search Terms
array at type guard
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
arr.at(0)
returns{} | undefined
π Expected behavior
arr.at(0)
returns{}
becausearr[0]
returns{}
The text was updated successfully, but these errors were encountered: