🏷️(react) add WithOptional type
This type allows to make only specific attributes optionnal where the existing Partial<T> makes all the attributes optionnal. Its first use will be for Modals.
This commit is contained in:
@@ -5,3 +5,7 @@ export type PartialNested<T> = {
|
|||||||
export type PartialExtendableNested<T> = {
|
export type PartialExtendableNested<T> = {
|
||||||
[K in keyof T]?: T[K] extends object ? PartialExtendableNested<T[K]> : T[K];
|
[K in keyof T]?: T[K] extends object ? PartialExtendableNested<T[K]> : T[K];
|
||||||
} & Record<PropertyKey, any>;
|
} & Record<PropertyKey, any>;
|
||||||
|
|
||||||
|
// From https://github.com/Microsoft/TypeScript/issues/25760#issuecomment-405931434.
|
||||||
|
export type WithOptional<T, K extends keyof T> = Omit<T, K> &
|
||||||
|
Partial<Pick<T, K>>;
|
||||||
|
|||||||
Reference in New Issue
Block a user