For a given object like:
class Product {
constructor(
public metadata: Metadata,
public topic: Topic,
public title = 'empty'
) {}
...
}
I want to create an interface:
interface State<T> {
}
such that TypeScript ensures that a product: State<Product> has the same structure as Product but its matching leaf-level properties are boolean. So product is supposed to have a title property of type boolean.
I had a look at the readonly example at mapped-types but in this case I probably need a composite:
interface State<T> {
[p in keyof T]: typeof T[p] === 'object' ? State<T[p]> : boolean;
}
Any ideas of how to make this work?