Extend interface object

Viewed 22

I've had a problem I couldn't solve in a 'pleaserable manner', so I'm wondering if some people here would know how to do it.

Say I have an interface with a specific property :

interface a{
  x: {
    property: string;
  }
}

If I have a second interface, that extends the first, and want to add properties to 'x', the compiler will throw an error, unless I add the previous property to b :

interface b extends a{ //Will give 'interface b incorectly extends interface a'
  x: {
    otherProperty: number; 
  }
}

interface b extends a{ //Will work
  x: {
    property: string;
    otherProperty: number; 
  }
}

Now, i'm wondering if there is a way to say to the compiler that the x property of b is equal to a's, something similar to :

interface b extends a{
  x extends a.x{
    otherProperty: number;
  }
}

Thank you for taking the time to read.

0 Answers
Related