Closed pabra closed 3 years ago
Thanks!
Looks not that complicated but I probably would implement it differently, e.g. defining the record runtype as:
export function record<T extends object>(
typemap: { [K in keyof T]: Runtype<T[K]> | Optional<T> },
): Runtype<OptionalRecord<T>> {
with function optional<T>(t: T): Optional<T>
.
But I'm not sure what that implies - will have to compare both approaches and see which works best.
I don't get the typemap type of { [K in keyof T]: Runtype<T[K]> | Optional<T> }
to work. Would be nice to see what you had in mind.
Thanks for providing this PR as a reference. I've now implemented optional by using a mechanism similar to type-fests conditionalExcept
and so I don't need the explicit optional symbol and omit and pick continue to work without modifying their return types.
I don't like the fix of the record related runtype (omit, pick, intersection) of the last commit. Any ideas? What do you think overall?
fixes #18