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
// TypeinterfaceAxisInfo{config: {min: number,max: number}}// DOESN'T WORK: Case 1: Using interfaceinterfaceAxesInfo{x: AxisInfoy: AxisInfo}constaxes: AxesInfo={x: {config: {min: 0,max: 50},},y: {config: {min: 0,max: 100},},}// => config.max is of `any` typeObject.values(axes).forEach(({ config })=>alert(config.max))// WORKS FINE: Case 2: Using union RecordtypeAxesInfo2=Record<"x"|"y",AxisInfo>constaxes2: AxesInfo2={x: {config: {min: 0,max: 50},},y: {config: {min: 0,max: 100},},}// => config.max is of type `number`Object.values(axes2).forEach(({ config })=>alert(config.max))
🙁 Actual behavior
Object.values(axes) is of type any[]. Object.values(axes2) is of type AxisInfo[], as expected.
🙂 Expected behavior
Object.values(axes) is of type AxisInfo[].
The text was updated successfully, but these errors were encountered:
marcelgerber
changed the title
Object.values can't infer interface type
Object.values can't infer type for interface
Aug 2, 2021
Bug Report
🔎 Search Terms
Object.values, any, interface
🕗 Version & Regression Information
This is the behavior in every version I tried, and I reviewed the FAQ for entries about
Object.values
.In particular, this happens in version 4.3.5.
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
Object.values(axes)
is of typeany[]
.Object.values(axes2)
is of typeAxisInfo[]
, as expected.🙂 Expected behavior
Object.values(axes)
is of typeAxisInfo[]
.The text was updated successfully, but these errors were encountered: