I have the following code:
interface InterfaceObject {
a: number;
}
type TypeObject = {
a: number;
}
type InterfaceObjectTest = InterfaceObject extends Record<string | symbol | number, unknown> ? true : false; // false
type TypeObjectTest = TypeObject extends Record<string | symbol | number, unknown> ? true : false; // true
InterfaceObjectTest and TypeObjectTest represent if their respective types are some kind of object. Since type and interface are mostly interchangeable, I would have expected both to be the same, true in this case, yet InterfaceObjectTest evaluates to false, while TypeObjectTest evaluates to true. Furthermore, when replacing unknown in the Record value, both evaluate to true.
Can someone explain what difference between type and interface is causing the different results?