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
All open issues referencing "Array.isArray" "typeguarding arrays from object values"
Playground link with relevant code
export function searchObject<T extends object>( obj: T, properties: (keyof T)[], ) { for (const property of properties) { const val = obj[property]; if (Array.isArray(val)) { val.forEach(() => {}); } } }
val may be an array, but Typescript reports that forEach is not defined on val because T[keyof T] cannot be an array.
val
val is 'narrowed' to T[keyof T] & any[]
T[keyof T] & any[]
The text was updated successfully, but these errors were encountered:
The change between origin/release-5.0 and origin/release-5.1 occurred at 84a09c7.
Sorry, something went wrong.
The originating change is being reverted. Track at #54845
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.
No branches or pull requests
Bug Report
π Search Terms
All open issues referencing "Array.isArray"
"typeguarding arrays from object values"
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
val
may be an array, but Typescript reports that forEach is not defined on val because T[keyof T] cannot be an array.π Expected behavior
val
is 'narrowed' toT[keyof T] & any[]
The text was updated successfully, but these errors were encountered: