mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[prop-types] Make ValidationMap not require a validator for every member (#31133)
* Make ValidationMap not require a validator for every member of the props interface * Fix InferProps when there are no required keys
This commit is contained in:
parent
4add980baf
commit
78e24e6d88
6
types/prop-types/index.d.ts
vendored
6
types/prop-types/index.d.ts
vendored
@ -41,12 +41,12 @@ export interface Requireable<T> extends Validator<T | undefined | null> {
|
||||
isRequired: Validator<NonNullable<T>>;
|
||||
}
|
||||
|
||||
export type ValidationMap<T> = { [K in keyof T]-?: Validator<T[K]> };
|
||||
export type ValidationMap<T> = { [K in keyof T]?: Validator<T[K]> };
|
||||
|
||||
export type InferType<V> = V extends Validator<infer T> ? T : any;
|
||||
export type InferProps<V> =
|
||||
& InferPropsInner<Pick<V, RequiredKeys<V>>>
|
||||
& Partial<InferPropsInner<Pick<V, OptionalKeys<V>>>>;
|
||||
& (RequiredKeys<V> extends undefined ? {} : InferPropsInner<Pick<V, RequiredKeys<V>>>)
|
||||
& (OptionalKeys<V> extends undefined ? {} : Partial<InferPropsInner<Pick<V, OptionalKeys<V>>>>);
|
||||
|
||||
export const any: Requireable<any>;
|
||||
export const array: Requireable<any[]>;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user