Skip to content

Commit

Permalink
wip(types): expose defineMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Aug 14, 2024
1 parent 6ed207a commit 1048050
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/runtime-core/src/apiDefineComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import type { SlotsType } from './componentSlots'
export type PublicProps = VNodeProps &
AllowedComponentProps &
ComponentCustomProps

type ResolveProps<PropsOrPropOptions, E extends EmitsOptions> = Readonly<
// fixed by xxxxxx
export type ResolveProps<PropsOrPropOptions, E extends EmitsOptions> = Readonly<
PropsOrPropOptions extends ComponentPropsOptions
? ExtractPropTypes<PropsOrPropOptions>
: PropsOrPropOptions
Expand Down
4 changes: 2 additions & 2 deletions packages/runtime-core/src/apiWatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ type MapSources<T, Immediate> = {
: T[K]
: never
}

type OnCleanup = (cleanupFn: () => void) => void
// fixed by xxxxxx
export type OnCleanup = (cleanupFn: () => void) => void

export interface WatchOptionsBase extends DebuggerOptions {
flush?: 'pre' | 'post' | 'sync'
Expand Down
159 changes: 158 additions & 1 deletion packages/runtime-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ export const DeprecationTypes = (
) as typeof _DeprecationTypes

// fixed by xxxxxx
export { defineComponent as defineMixin } from './apiDefineComponent'
export type { OnCleanup } from './apiWatch'
import type { CreateAppFunction } from './apiCreateApp'
export let createApp: CreateAppFunction<Element>
export let createSSRApp: CreateAppFunction<Element>
Expand Down Expand Up @@ -463,3 +463,160 @@ export declare function useModel<R>(
name: string,
options?: any,
): ModelRef<R, string>

import type { ObjectDirective } from './directives'
export declare const vShow: ObjectDirective

import type {
ComponentInjectOptions,
ComponentOptionsMixin,
ComponentOptionsWithArrayProps,
ComponentOptionsWithObjectProps,
ComponentOptionsWithoutProps,
ComputedOptions,
MethodOptions,
} 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'

export declare function defineMixin<
Props = {},
RawBindings = {},
D = {},
C extends ComputedOptions = {},
M extends MethodOptions = {},
Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
E extends EmitsOptions = {},
EE extends string = string,
S extends SlotsType = {},
I extends ComponentInjectOptions = {},
II extends string = string,
>(
options: ComponentOptionsWithoutProps<
Props,
RawBindings,
D,
C,
M,
Mixin,
Extends,
E,
EE,
I,
II,
S
>,
): DefineComponent<
Props,
RawBindings,
D,
C,
M,
Mixin,
Extends,
E,
EE,
PublicProps,
ResolveProps<Props, E>,
ExtractDefaultPropTypes<Props>,
{}
>
export declare function defineMixin<
PropNames extends string,
RawBindings,
D = {},
C extends ComputedOptions = {},
M extends MethodOptions = {},
Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
E extends EmitsOptions = {},
EE extends string = string,
S extends SlotsType = {},
I extends ComponentInjectOptions = {},
II extends string = string,
Props = Readonly<{
[key in PropNames]?: any
}>,
>(
options: ComponentOptionsWithArrayProps<
PropNames,
RawBindings,
D,
C,
M,
Mixin,
Extends,
E,
EE,
I,
II,
S
>,
): DefineComponent<
Props,
RawBindings,
D,
C,
M,
Mixin,
Extends,
E,
EE,
PublicProps,
ResolveProps<Props, E>,
ExtractDefaultPropTypes<Props>,
{}
>
export declare function defineMixin<
PropsOptions extends Readonly<ComponentPropsOptions>,
RawBindings,
D = {},
C extends ComputedOptions = {},
M extends MethodOptions = {},
Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
E extends EmitsOptions = {},
EE extends string = string,
S extends SlotsType = {},
I extends ComponentInjectOptions = {},
II extends string = string,
>(
options: ComponentOptionsWithObjectProps<
PropsOptions,
RawBindings,
D,
C,
M,
Mixin,
Extends,
E,
EE,
I,
II,
S
>,
): DefineComponent<
PropsOptions,
RawBindings,
D,
C,
M,
Mixin,
Extends,
E,
EE,
PublicProps,
ResolveProps<PropsOptions, E>,
ExtractDefaultPropTypes<PropsOptions>,
{}
>

0 comments on commit 1048050

Please sign in to comment.