I've defined an interface with different types:
interface MyInterface {
Name1: { userId: string }
Name2: { bookingId: string }
}
Below that, I have a type that takes an object of type
{ [key: keyof MyInterface]: boolean }
:
type TProperties<T extends Record<keyof MyInterface, boolean>> = {
[P in keyof T]: P extends keyof MyInterface ? Pick<MyInterface, P> : never
}
However, when I try to use it like this:
TProperties<{ Name1: true }> // Error <large obj redacted> is not assignable to type 'Record<keyof MyInterface, boolean>'.
What am I doing wrong in the code above?