UNPKG

4.88 kBTypeScriptView Raw
1import { AllowedComponentProps } from 'vue';
2import { ComponentCustomProps } from 'vue';
3import { ComponentOptions } from 'vue';
4import { ComponentPublicInstance } from 'vue';
5import { EmitsOptions } from 'vue';
6import { Prop } from 'vue';
7import { PropType } from 'vue';
8import { Ref } from 'vue';
9import { ShallowUnwrapRef } from 'vue';
10import { VNode } from 'vue';
11import { VNodeProps } from 'vue';
12
13export declare interface ClassComponentHooks {
14 data?(): object;
15 beforeCreate?(): void;
16 created?(): void;
17 beforeMount?(): void;
18 mounted?(): void;
19 beforeUnmount?(): void;
20 unmounted?(): void;
21 beforeUpdate?(): void;
22 updated?(): void;
23 activated?(): void;
24 deactivated?(): void;
25 render?(): VNode | void;
26 errorCaptured?(err: Error, vm: Vue, info: string): boolean | undefined;
27 serverPrefetch?(): Promise<unknown>;
28}
29
30export declare function createDecorator(factory: (options: ComponentOptions, key: string, index: number) => void): VueDecorator;
31
32export declare type DefaultFactory<T> = (props: Record<string, unknown>) => T | null | undefined;
33
34export declare type DefaultKeys<P> = {
35 [K in keyof P]: P[K] extends WithDefault<any> ? K : never;
36}[keyof P];
37
38export declare type ExtractDefaultProps<P> = {
39 [K in DefaultKeys<P>]: P[K] extends WithDefault<infer T> ? T : never;
40};
41
42export declare type ExtractInstance<T> = T extends VueMixin<infer V> ? V : never;
43
44export declare type ExtractProps<P> = {
45 [K in keyof P]: P[K] extends WithDefault<infer T> ? T : P[K];
46};
47
48export declare type MixedVueBase<Mixins extends VueMixin[]> = Mixins extends (infer T)[] ? VueConstructor<UnionToIntersection<ExtractInstance<T>> & Vue> : never;
49
50export declare function mixins<T extends VueMixin[]>(...Ctors: T): MixedVueBase<T>;
51
52export declare function Options<V extends Vue>(options: ComponentOptions & ThisType<V>): <VC extends VueConstructor<VueBase>>(target: VC) => VC;
53
54export declare function prop<T>(options: PropOptionsWithDefault<T>): WithDefault<T>;
55
56export declare function prop<T>(options: PropOptionsWithRequired<T>): T;
57
58export declare function prop<T>(options: Prop<T>): T | undefined;
59
60export declare interface PropOptions<T = any, D = T> {
61 type?: PropType<T> | true | null;
62 required?: boolean;
63 default?: D | DefaultFactory<D> | null | undefined | object;
64 validator?(value: unknown): boolean;
65}
66
67export declare interface PropOptionsWithDefault<T, D = T> extends PropOptions<T, D> {
68 default: PropOptions<T, D>['default'];
69}
70
71export declare interface PropOptionsWithRequired<T, D = T> extends PropOptions<T, D> {
72 required: true;
73}
74
75export declare type PublicProps = VNodeProps & AllowedComponentProps & ComponentCustomProps;
76
77export declare function setup<R>(setupFn: () => R): UnwrapSetupValue<UnwrapPromise<R>>;
78
79export declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
80
81export declare type UnwrapPromise<T> = T extends Promise<infer R> ? R : T;
82
83export declare type UnwrapSetupValue<T> = T extends Ref<infer R> ? R : ShallowUnwrapRef<T>;
84
85export declare type Vue<Props = unknown, Emits extends EmitsOptions = {}, DefaultProps = {}> = ComponentPublicInstance<Props, {}, {}, {}, {}, Emits, PublicProps, DefaultProps, true> & ClassComponentHooks;
86
87export declare const Vue: VueConstructor;
88
89export declare type VueBase = Vue<unknown, never[]>;
90
91export declare interface VueConstructor<V extends VueBase = Vue> extends VueMixin<V> {
92 new (...args: any[]): V;
93 registerHooks(keys: string[]): void;
94 props<P extends {
95 new (): unknown;
96 }>(Props: P): VueConstructor<V & VueWithProps<InstanceType<P>>>;
97}
98
99export declare interface VueDecorator {
100 (Ctor: VueConstructor<VueBase>): void;
101 (target: VueBase, key: string): void;
102 (target: VueBase, key: string, index: number): void;
103}
104
105export declare type VueMixin<V extends VueBase = VueBase> = VueStatic & {
106 prototype: V;
107};
108
109export declare interface VueStatic {
110 /* Excluded from this release type: __vccCache */
111 /* Excluded from this release type: __vccBase */
112 /* Excluded from this release type: __vccDecorators */
113 /* Excluded from this release type: __vccExtend */
114 /* Excluded from this release type: __vccHooks */
115 /* Excluded from this release type: __vccOpts */
116 /* Excluded from this release type: render */
117 /* Excluded from this release type: ssrRender */
118 /* Excluded from this release type: __file */
119 /* Excluded from this release type: __cssModules */
120 /* Excluded from this release type: __scopeId */
121 /* Excluded from this release type: __hmrId */
122}
123
124export declare type VueWithProps<P> = Vue<ExtractProps<P>, {}, ExtractDefaultProps<P>> & ExtractProps<P>;
125
126export declare interface WithDefault<T> {
127 [withDefaultSymbol]: T;
128}
129
130declare const withDefaultSymbol: unique symbol;
131
132export { }