From 022b43a17cb5b99c5d5255a2a63b992954e09bc0 Mon Sep 17 00:00:00 2001 From: liximomo Date: Thu, 19 Sep 2019 10:56:04 +0800 Subject: [PATCH] feat(type): add "Required" type parameter to "PropOptions" --- src/component/componentProps.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/component/componentProps.ts b/src/component/componentProps.ts index 6251ef15..8b2899bf 100644 --- a/src/component/componentProps.ts +++ b/src/component/componentProps.ts @@ -1,14 +1,14 @@ import { Data } from './component'; export type ComponentPropsOptions

= { - [K in keyof P]: Prop | null; + [K in keyof P]: Prop | null; }; -type Prop = PropOptions | PropType; +type Prop = PropOptions | PropType; -export interface PropOptions { +export interface PropOptions { type?: PropType | null; - required?: boolean; + required?: Required; default?: T | null | undefined | (() => T | null | undefined); validator?(value: any): boolean; } @@ -34,7 +34,7 @@ type InferPropType = T extends null ? any // somehow `ObjectConstructor` when inferred from { (): T } becomes `any` : T extends ObjectConstructor | { type: ObjectConstructor } ? { [key: string]: any } - : T extends Prop + : T extends Prop ? V : T;