I have defined a recursive SerializableRecord interface that I defined with the help of recursive type references. This interface can be changed.
type Serializable =
| string
| number
| boolean
| null
| undefined
| SerializableArray
| SerializableRecord;
interface SerializableArray extends Array<Serializable> {}
interface SerializableRecord extends Record<string, Serializable> {}
I have another imported interface (which means I can't change it):
interface ExternalInterface {
attr: string;
}
Now if I try to do the following I get an error:
const x: ExternalInterface = {attr: 'a'};
const y: SerializableRecord = x;
// Throws a TS error: "Index signature is missing in type 'ExternalInterface'"
Is there a way to make those two entities compatible, without introducing any or unknown?