#Check if given type is empty object
9 messages · Page 1 of 1 (latest)
@warped swift I'd be careful with this because {} doesn't really mean "empty object", it means an interface with no specified properties, but this seems to do essentially what you want?
type HasNoKnownProperties<T> = {} extends T ? "Yes" : "No";
type Example1 = HasNoKnownProperties<{}>
// ^? - type Example1 = "Yes"
type Example2 = HasNoKnownProperties<{ x: string }>
// ^? - type Example2 = "No"