-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
Description
π Search Terms
object.entires incorrect type narrowed
π Version & Regression Information
I can experience this on v5.8.3. I also checked back to 5.0.4 on the playground and see the same behavior
β― Playground Link
π» Code
function fn(foo: { bar?: number | undefined }) {
// typescript thinks _arr_ is `[string, number][]` when actually it is `[string, number | undefined][]`
const arr = Object.entries(foo);
console.log(arr);
}
fn({
bar: undefined
});π Actual behavior
The type from Object.entries is narrowed
π Expected behavior
Object.entries(foo) produces a type output that is [string, number | undefined][] when foo has type { bar?: number | undefined }
Additional information about the issue
No response
jtbandes
Metadata
Metadata
Assignees
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code