Skip to content

Commit

Permalink
chore: remove unused arg for ExtractPropTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Sep 16, 2020
1 parent a072d50 commit e1905a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
22 changes: 6 additions & 16 deletions packages/runtime-core/src/componentProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,11 @@ type PropMethod<T, TConstructor = any> = T extends (...args: any) => any // if i
? { new (): TConstructor; (): T; readonly prototype: TConstructor } // Create Function like constructor
: never

type RequiredKeys<T, MakeDefaultRequired> = {
[K in keyof T]: T[K] extends
| { required: true }
| (MakeDefaultRequired extends true ? { default: any } : never)
? K
: never
type RequiredKeys<T> = {
[K in keyof T]: T[K] extends { required: true } | { default: any } ? K : never
}[keyof T]

type OptionalKeys<T, MakeDefaultRequired> = Exclude<
keyof T,
RequiredKeys<T, MakeDefaultRequired>
>
type OptionalKeys<T> = Exclude<keyof T, RequiredKeys<T>>

type DefaultKeys<T> = {
[K in keyof T]: T[K] extends { default: any } ? K : never
Expand All @@ -90,12 +83,9 @@ type InferPropType<T> = T extends null
? boolean
: T extends Prop<infer V, infer D> ? (unknown extends V ? D : V) : T

export type ExtractPropTypes<
O,
MakeDefaultRequired extends boolean = true
> = O extends object
? { [K in RequiredKeys<O, MakeDefaultRequired>]: InferPropType<O[K]> } &
{ [K in OptionalKeys<O, MakeDefaultRequired>]?: InferPropType<O[K]> }
export type ExtractPropTypes<O> = O extends object
? { [K in RequiredKeys<O>]: InferPropType<O[K]> } &
{ [K in OptionalKeys<O>]?: InferPropType<O[K]> }
: { [K in string]: any }

const enum BooleanFlags {
Expand Down
6 changes: 4 additions & 2 deletions packages/runtime-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ----------------------------------------------------------------
Expand Down Expand Up @@ -166,6 +166,7 @@ export {
ComponentCustomProps,
AllowedComponentProps
} from './component'
export { DefineComponent } from './apiDefineComponent'
export {
ComponentOptions,
ComponentOptionsMixin,
Expand Down Expand Up @@ -198,7 +199,8 @@ export {
PropType,
ComponentPropsOptions,
ComponentObjectPropsOptions,
ExtractPropTypes
ExtractPropTypes,
ExtractDefaultPropTypes
} from './componentProps'
export {
Directive,
Expand Down

0 comments on commit e1905a9

Please sign in to comment.