You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typeA=Record<string,string>&{name?: string}consta: A={}a.name=undefinedconstvalues=Object.values(a)//values type is string[] when in fact it contains 'undefined'console.log(values)
π Actual behavior
The type does not reflect the reality, the type of values is string[] where in fact the array can contain undefined
π Expected behavior
I expect typescript to infer the type to be (string | undefined)[]
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered:
π Search Terms
"Object.keys Record", "record with field"
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?ssl=7&ssc=20&pln=1&pc=1#code/C4TwDgpgBAglC8UBKEDGB7ATgEwDwGdhMBLAOwHMAaKQkigPigDIoBvUgQwFsIB+ALhpEy5AL4AocRlKEoHQXESsJHAHSceCKAFdS2CADMyEbFPQzgUAG4cANtoj4tAeQBGAKzTBVN+44AUHACU4gD0ob4OTqCQUMROtCIA2gC6UADuABYQpHG5BhyolsSW0sAcZE4A5Lr6RqQmVWYy6LYQqrbo5P6RjkFAA
π» Code
π Actual behavior
The type does not reflect the reality, the type of
values
isstring[]
where in fact the array can containundefined
π Expected behavior
I expect typescript to infer the type to be
(string | undefined)[]
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: