I want to check if a type is an empty object and if thats the case map that to the void type.
type notEmpty<T> = T extends {}
? void
: T;
The above code does not work because evyr object extends the empty object.
Another approach was to turn it around:
type notEmpty2<T> = T extends { any: any }
? void
: T;
But that would match only the object with the property any not any property.
You can also check whether
Thas some keys:Playground