Someone sent over a type definition from a 3rd party library:
interface UpdateRequest {
data?: ValueRange[];
options?: Options
}
I am trying to implement a method with the following signature:
update(params: RequiredOnly<UpdateRequest, 'data'>) {
//...
}
The goal is to use a type utility called RequiredOnly to only require the 'data' key, not both 'data' and 'options' like the Required utility does.
Can this RequiredOnly type utility be created successfully?
I am facing a roadblock here:
type RequiredOnly<T, a extends keyof T> = {
[K in keyof T extends a ? a : never ]-?: T[K]
}