This may be a limitation in the type system, but thought I'd drop this proposal here. The idea here is that there should be some way of expressing that P is an object with keys that are a subset of the keys of T, then those keys that are missing on P from T are required to be supplied as U.
interface IComplete {
a: string;
b: string
}
function partial<T, P extends Partial<T>>(defaults: P) {
return function<U extends MissingFrom<T, P>>(remaining: U) {
const complete: T = { ...defaults, ...remaining };
return complete;
}
}
const curried = partial({a:"foo"});
const bar: IComplete = curried({b:"bar"});
const baz: IComplete = curried({b:"baz"});
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too