Skip to content

Commit

Permalink
wip(types): defineMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Aug 16, 2024
1 parent 1048050 commit 77e379e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 57 deletions.
8 changes: 7 additions & 1 deletion packages/runtime-core/src/componentOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,13 @@ export type ComponentInjectOptions = string[] | ObjectInjectOptions

type ObjectInjectOptions = Record<
string | symbol,
string | symbol | { from?: string | symbol; default?: unknown }
| string
| symbol
| {
type?: unknown // fixed by uts 给 inject 补充类型信息
from?: string | symbol
default?: unknown
}
>

export type InjectToObject<T extends ComponentInjectOptions> =
Expand Down
65 changes: 9 additions & 56 deletions packages/runtime-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ export declare const vShow: ObjectDirective

import type {
ComponentInjectOptions,
ComponentOptions,
ComponentOptionsMixin,
ComponentOptionsWithArrayProps,
ComponentOptionsWithObjectProps,
Expand All @@ -478,15 +479,8 @@ import type {
} from './componentOptions'
import type { EmitsOptions } from './componentEmits'
import type { SlotsType } from './componentSlots'
import type {
DefineComponent,
PublicProps,
ResolveProps,
} from './apiDefineComponent'
import type {
ComponentPropsOptions,
ExtractDefaultPropTypes,
} from './componentProps'
import type { ResolveProps } from './apiDefineComponent'
import type { ComponentPropsOptions } from './componentProps'

export declare function defineMixin<
Props = {},
Expand Down Expand Up @@ -516,25 +510,11 @@ export declare function defineMixin<
II,
S
>,
): DefineComponent<
Props,
RawBindings,
D,
C,
M,
Mixin,
Extends,
E,
EE,
PublicProps,
ResolveProps<Props, E>,
ExtractDefaultPropTypes<Props>,
{}
>
): ComponentOptions<Props, RawBindings, D, C, M, any, any, E, S>
export declare function defineMixin<
PropNames extends string,
RawBindings,
D = {},
D,
C extends ComputedOptions = {},
M extends MethodOptions = {},
Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
Expand Down Expand Up @@ -562,25 +542,11 @@ export declare function defineMixin<
II,
S
>,
): DefineComponent<
Props,
RawBindings,
D,
C,
M,
Mixin,
Extends,
E,
EE,
PublicProps,
ResolveProps<Props, E>,
ExtractDefaultPropTypes<Props>,
{}
>
): ComponentOptions<Props, RawBindings, D, C, M, any, any, E, S>
export declare function defineMixin<
PropsOptions extends Readonly<ComponentPropsOptions>,
RawBindings,
D = {},
D,
C extends ComputedOptions = {},
M extends MethodOptions = {},
Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
Expand All @@ -590,6 +556,7 @@ export declare function defineMixin<
S extends SlotsType = {},
I extends ComponentInjectOptions = {},
II extends string = string,
Props = ResolveProps<PropsOptions, EmitsOptions>,
>(
options: ComponentOptionsWithObjectProps<
PropsOptions,
Expand All @@ -605,18 +572,4 @@ export declare function defineMixin<
II,
S
>,
): DefineComponent<
PropsOptions,
RawBindings,
D,
C,
M,
Mixin,
Extends,
E,
EE,
PublicProps,
ResolveProps<PropsOptions, E>,
ExtractDefaultPropTypes<PropsOptions>,
{}
>
): ComponentOptions<Props, RawBindings, D, C, M, any, any, E, S>

0 comments on commit 77e379e

Please sign in to comment.