diff --git a/packages/runtime-core/src/componentProps.ts b/packages/runtime-core/src/componentProps.ts index 3a111452b44..0fde127a28f 100644 --- a/packages/runtime-core/src/componentProps.ts +++ b/packages/runtime-core/src/componentProps.ts @@ -63,18 +63,11 @@ type PropMethod = T extends (...args: any) => any // if i ? { new (): TConstructor; (): T; readonly prototype: TConstructor } // Create Function like constructor : never -type RequiredKeys = { - [K in keyof T]: T[K] extends - | { required: true } - | (MakeDefaultRequired extends true ? { default: any } : never) - ? K - : never +type RequiredKeys = { + [K in keyof T]: T[K] extends { required: true } | { default: any } ? K : never }[keyof T] -type OptionalKeys = Exclude< - keyof T, - RequiredKeys -> +type OptionalKeys = Exclude> type DefaultKeys = { [K in keyof T]: T[K] extends { default: any } ? K : never @@ -90,12 +83,9 @@ type InferPropType = T extends null ? boolean : T extends Prop ? (unknown extends V ? D : V) : T -export type ExtractPropTypes< - O, - MakeDefaultRequired extends boolean = true -> = O extends object - ? { [K in RequiredKeys]: InferPropType } & - { [K in OptionalKeys]?: InferPropType } +export type ExtractPropTypes = O extends object + ? { [K in RequiredKeys]: InferPropType } & + { [K in OptionalKeys]?: InferPropType } : { [K in string]: any } const enum BooleanFlags { diff --git a/packages/runtime-core/src/index.ts b/packages/runtime-core/src/index.ts index 75dd69fbe8f..26c27d544e6 100644 --- a/packages/runtime-core/src/index.ts +++ b/packages/runtime-core/src/index.ts @@ -41,7 +41,7 @@ export { } from './apiLifecycle' export { provide, inject } from './apiInject' export { nextTick } from './scheduler' -export { defineComponent, DefineComponent } from './apiDefineComponent' +export { defineComponent } from './apiDefineComponent' export { defineAsyncComponent } from './apiAsyncComponent' // Advanced API ---------------------------------------------------------------- @@ -166,6 +166,7 @@ export { ComponentCustomProps, AllowedComponentProps } from './component' +export { DefineComponent } from './apiDefineComponent' export { ComponentOptions, ComponentOptionsMixin, @@ -198,7 +199,8 @@ export { PropType, ComponentPropsOptions, ComponentObjectPropsOptions, - ExtractPropTypes + ExtractPropTypes, + ExtractDefaultPropTypes } from './componentProps' export { Directive,