import Vue$1, { VNode, VueConstructor, ComponentOptions, AsyncComponent, VNodeDirective, CreateElement } from 'vue';
import { Component as Component$1, AsyncComponent as AsyncComponent$1 } from 'vue/types/options';
import { VNodeChildren, VNode as VNode$1, VNodeData } from 'vue/types/vnode';
declare type Data = {
[key: string]: unknown;
};
declare type ComponentPropsOptions
= ComponentObjectPropsOptions
| string[];
declare type ComponentObjectPropsOptions
= {
[K in keyof P]: Prop
| null;
};
declare type Prop = PropOptions | PropType;
declare type DefaultFactory = () => T | null | undefined;
interface PropOptions {
type?: PropType | true | null;
required?: boolean;
default?: D | DefaultFactory | null | undefined | object;
validator?(value: unknown): boolean;
}
declare type PropType = PropConstructor | PropConstructor[];
declare type PropConstructor = {
new (...args: any[]): T & object;
} | {
(): T;
} | {
new (...args: string[]): Function;
};
declare type RequiredKeys = {
[K in keyof T]: T[K] extends {
required: true;
} | {
default: any;
} | BooleanConstructor | {
type: BooleanConstructor;
} ? K : never;
}[keyof T];
declare type OptionalKeys = Exclude>;
declare type ExtractFunctionPropType = any[], TResult = any> = T extends (...args: TArgs) => TResult ? T : never;
declare type ExtractCorrectPropType = T extends Function ? ExtractFunctionPropType : Exclude;
declare type InferPropType = T extends null ? any : T extends {
type: null | true;
} ? any : T extends ObjectConstructor | {
type: ObjectConstructor;
} ? Record : T extends BooleanConstructor | {
type: BooleanConstructor;
} ? boolean : T extends DateConstructor | {
type: DateConstructor;
} ? Date : T extends FunctionConstructor | {
type: FunctionConstructor;
} ? Function : T extends Prop ? unknown extends V ? D extends null | undefined ? V : D : ExtractCorrectPropType : T;
declare type ExtractPropTypes = {
[K in keyof Pick>]: InferPropType;
} & {
[K in keyof Pick>]?: InferPropType;
};
declare type DefaultKeys = {
[K in keyof T]: T[K] extends {
default: any;
} | BooleanConstructor | {
type: BooleanConstructor;
} ? T[K] extends {
type: BooleanConstructor;
required: true;
} ? never : K : never;
}[keyof T];
declare type ExtractDefaultPropTypes = O extends object ? {
[K in keyof Pick>]: InferPropType;
} : {};
declare type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
declare type Slot = (...args: any[]) => VNode[];
declare type InternalSlots = {
[name: string]: Slot | undefined;
};
declare type ObjectEmitsOptions = Record any) | null>;
declare type EmitsOptions = ObjectEmitsOptions | string[];
declare type EmitFn = Options extends Array ? (event: V, ...args: any[]) => ReturnType : {} extends Options ? (event: string, ...args: any[]) => ReturnType : UnionToIntersection<{
[key in Event]: Options[key] extends (...args: infer Args) => any ? (event: key, ...args: Args) => ReturnType : (event: key, ...args: any[]) => ReturnType;
}[Event]>;
declare type ComponentRenderEmitFn = EmitFn;
declare type Slots = Readonly;
interface SetupContext {
attrs: Data;
slots: Slots;
emit: EmitFn;
/**
* @deprecated not available in Vue 2
*/
expose: (exposed?: Record) => void;
/**
* @deprecated not available in Vue 3
*/
readonly parent: ComponentInstance | null;
/**
* @deprecated not available in Vue 3
*/
readonly root: ComponentInstance;
/**
* @deprecated not available in Vue 3
*/
readonly listeners: {
[key in string]?: Function;
};
/**
* @deprecated not available in Vue 3
*/
readonly refs: {
[key: string]: Vue | Element | Vue[] | Element[];
};
}
/**
* We expose a subset of properties on the internal instance as they are
* useful for advanced external libraries and tools.
*/
declare interface ComponentInternalInstance {
uid: number;
type: Record;
parent: ComponentInternalInstance | null;
root: ComponentInternalInstance;
/**
* Vnode representing this component in its parent's vdom tree
*/
vnode: VNode;
/**
* Root vnode of this component's own vdom tree
*/
/**
* The reactive effect for rendering and patching the component. Callable.
*/
update: Function;
data: Data;
props: Data;
attrs: Data;
refs: Data;
emit: EmitFn;
slots: InternalSlots;
emitted: Record | null;
proxy: ComponentInstance;
isMounted: boolean;
isUnmounted: boolean;
isDeactivated: boolean;
}
declare function getCurrentInstance(): ComponentInternalInstance | null;
declare type EmitsToProps = T extends string[] ? {
[K in string & `on${Capitalize}`]?: (...args: any[]) => any;
} : T extends ObjectEmitsOptions ? {
[K in string & `on${Capitalize}`]?: K extends `on${infer C}` ? T[Uncapitalize] extends null ? (...args: any[]) => any : (...args: T[Uncapitalize] extends (...args: infer P) => any ? P : never) => any : never;
} : {};
declare type ComponentInstance = InstanceType;
declare type ComponentRenderProxy = {
$data: D;
$props: Readonly & Omit : P & PublicProps>;
$attrs: Record;
$emit: ComponentRenderEmitFn>;
} & Readonly & ShallowUnwrapRef & D & M & ExtractComputedReturns & Omit;
declare type VueConstructorProxy & ({} extends Emits ? {} : EmitsToProps)> = Omit & {
new (...args: any[]): ComponentRenderProxy, Data, Computed, Methods, Mixin, Extends, Emits, Props, ExtractDefaultPropTypes, true>;
};
declare type DefaultData = object | ((this: V) => object);
declare type DefaultMethods = {
[key: string]: (this: V, ...args: any[]) => any;
};
declare type DefaultComputed = {
[key: string]: any;
};
declare type VueProxy, Computed extends ComputedOptions = DefaultComputed, Methods extends MethodOptions = DefaultMethods, Mixin = {}, Extends = {}, Emits extends EmitsOptions = {}> = ComponentOptions & Data, Methods, Computed, PropsOptions, ExtractPropTypes> & VueConstructorProxy;
declare type ComponentPublicInstance = {
$: ComponentInternalInstance;
$data: D;
$props: MakeDefaultsOptional extends true ? Partial & Omit : P & PublicProps;
$attrs: Data;
$refs: Data;
$slots: Slots;
$root: ComponentPublicInstance | null;
$parent: ComponentPublicInstance | null;
$emit: EmitFn;
$el: any;
$forceUpdate: () => void;
$nextTick: typeof nextTick;
$watch(source: string | Function, cb: Function, options?: WatchOptions): WatchStopHandle;
} & P & ShallowUnwrapRef & UnwrapNestedRefs & ExtractComputedReturns & M;
declare type ComputedGetter$1 = (ctx?: any) => T;
declare type ComputedSetter$1 = (v: T) => void;
interface WritableComputedOptions$1 {
get: ComputedGetter$1;
set: ComputedSetter$1;
}
declare type ComputedOptions = Record | WritableComputedOptions$1>;
interface MethodOptions {
[key: string]: Function;
}
declare type SetupFunction = (this: void, props: Readonly, ctx: SetupContext) => RawBindings | (() => VNode | null) | void;
interface ComponentOptionsBase extends Omit, 'data' | 'computed' | 'method' | 'setup' | 'props'> {
[key: string]: any;
data?: (this: Props & Vue$1, vm: Props) => D;
computed?: C;
methods?: M;
}
declare type ExtractComputedReturns = {
[key in keyof T]: T[key] extends {
get: (...args: any[]) => infer TReturn;
} ? TReturn : T[key] extends (...args: any[]) => infer TReturn ? TReturn : never;
};
declare type ComponentOptionsWithProps> = ComponentOptionsBase & {
props?: PropsOptions;
emits?: Emits & ThisType;
setup?: SetupFunction;
} & ThisType>;
declare type ComponentOptionsWithArrayProps> = ComponentOptionsBase & {
props?: PropNames[];
emits?: Emits & ThisType;
setup?: SetupFunction;
} & ThisType>;
declare type ComponentOptionsWithoutProps = ComponentOptionsBase & {
props?: undefined;
emits?: Emits & ThisType;
setup?: SetupFunction;
} & ThisType>;
declare type AnyObject = Record;
declare type Equal = (() => U extends Left ? 1 : 0) extends (() => U extends Right ? 1 : 0) ? true : false;
declare type HasDefined = Equal extends true ? false : true;
/**
* overload 1: object format with no props
*/
declare function defineComponent(options: ComponentOptionsWithoutProps<{}, RawBindings, D, C, M, Mixin, Extends, Emits>): VueProxy<{}, RawBindings, D, C, M, Mixin, Extends, Emits>;
/**
* overload 2: object format with array props declaration
* props inferred as `{ [key in PropNames]?: any }`
*
* return type is for Vetur and TSX support
*/
declare function defineComponent(options: ComponentOptionsWithArrayProps): VueProxy, RawBindings, D, C, M, Mixin, Extends, Emits>;
/**
* overload 3: object format with object props declaration
*
* see `ExtractPropTypes` in './componentProps.ts'
*/
declare function defineComponent(options: HasDefined extends true ? ComponentOptionsWithProps : ComponentOptionsWithProps): VueProxy;
declare type Component = VueProxy;
declare type ComponentOrComponentOptions = Component | ComponentOptionsWithoutProps | ComponentOptionsWithArrayProps | ComponentOptionsWithProps;
declare type AsyncComponentResolveResult = T | {
default: T;
};
declare type AsyncComponentLoader = () => Promise;
interface AsyncComponentOptions {
loader: AsyncComponentLoader;
loadingComponent?: ComponentOrComponentOptions;
errorComponent?: ComponentOrComponentOptions;
delay?: number;
timeout?: number;
suspensible?: boolean;
onError?: (error: Error, retry: () => void, fail: () => void, attempts: number) => any;
}
declare function defineAsyncComponent(source: AsyncComponentLoader | AsyncComponentOptions): AsyncComponent;
declare type DirectiveModifiers = Record;
interface DirectiveBinding extends Readonly {
readonly modifiers: DirectiveModifiers;
readonly value: V;
readonly oldValue: V | null;
}
declare type DirectiveHook = (el: T, binding: DirectiveBinding, vnode: VNode, prevVNode: Prev) => void;
interface ObjectDirective {
bind?: DirectiveHook;
inserted?: DirectiveHook;
update?: DirectiveHook;
componentUpdated?: DirectiveHook;
unbind?: DirectiveHook;
}
declare type FunctionDirective = DirectiveHook;
declare type Directive = ObjectDirective | FunctionDirective;
declare const Plugin: {
install: (Vue: VueConstructor) => void;
};
declare const _refBrand: unique symbol;
interface Ref {
readonly [_refBrand]: true;
value: T;
}
interface WritableComputedRef extends Ref {
/**
* `effect` is added to be able to differentiate refs from computed properties.
* **Differently from Vue 3, it's just `true`**. This is because there is no equivalent
* of `ReactiveEffect` in `@vue/composition-api`.
*/
effect: true;
}
interface ComputedRef extends WritableComputedRef {
readonly value: T;
}
declare type ToRefs = {
[K in keyof T]: Ref;
};
declare type CollectionTypes = IterableCollections | WeakCollections;
declare type IterableCollections = Map | Set;
declare type WeakCollections = WeakMap | WeakSet;
declare type BaseTypes = string | number | boolean | Node | Window | Date;
declare type ShallowUnwrapRef = {
[K in keyof T]: T[K] extends Ref ? V : T[K];
};
declare type UnwrapRef = T extends Ref ? UnwrapRefSimple : UnwrapRefSimple;
declare type UnwrapRefSimple = T extends Function | CollectionTypes | BaseTypes | Ref ? T : T extends Array ? {
[K in keyof T]: UnwrapRefSimple;
} : T extends object ? {
[P in keyof T]: P extends symbol ? T[P] : UnwrapRef;
} : T;
interface RefOption {
get(): T;
set?(x: T): void;
}
declare class RefImpl implements Ref {
readonly [_refBrand]: true;
value: T;
constructor({ get, set }: RefOption);
}
declare function createRef(options: RefOption, isReadonly?: boolean, isComputed?: boolean): RefImpl;
declare function ref(raw: T): T extends Ref ? T : Ref>;
declare function ref(raw: T): Ref>;
declare function ref(): Ref;
declare function isRef(value: any): value is Ref;
declare function unref(ref: T | Ref): T;
declare function toRefs(obj: T): ToRefs;
declare type CustomRefFactory = (track: () => void, trigger: () => void) => {
get: () => T;
set: (value: T) => void;
};
declare function customRef(factory: CustomRefFactory): Ref;
declare function toRef(object: T, key: K): Ref;
declare function shallowRef(value: T): T extends Ref ? T : Ref;
declare function shallowRef(value: T): Ref;
declare function shallowRef(): Ref;
declare function triggerRef(value: any): void;
declare function proxyRefs(objectWithRefs: T): ShallowUnwrapRef;
declare function isRaw(obj: any): boolean;
declare function isReactive(obj: any): boolean;
declare function shallowReactive(obj: T): T;
/**
* Make obj reactivity
*/
declare function reactive(obj: T): UnwrapRef;
/**
* Make sure obj can't be a reactive
*/
declare function markRaw(obj: T): T;
declare function toRaw(observed: T): T;
declare function isReadonly(obj: any): boolean;
declare type Primitive = string | number | boolean | bigint | symbol | undefined | null;
declare type Builtin = Primitive | Function | Date | Error | RegExp;
declare type DeepReadonly = T extends Builtin ? T : T extends Map ? ReadonlyMap, DeepReadonly> : T extends ReadonlyMap ? ReadonlyMap, DeepReadonly> : T extends WeakMap ? WeakMap, DeepReadonly> : T extends Set ? ReadonlySet> : T extends ReadonlySet ? ReadonlySet> : T extends WeakSet ? WeakSet> : T extends Promise ? Promise> : T extends {} ? {
readonly [K in keyof T]: DeepReadonly;
} : Readonly;
declare type UnwrapNestedRefs = T extends Ref ? T : UnwrapRefSimple;
/**
* **In @vue/composition-api, `reactive` only provides type-level readonly check**
*
* Creates a readonly copy of the original object. Note the returned copy is not
* made reactive, but `readonly` can be called on an already reactive object.
*/
declare function readonly(target: T): DeepReadonly>;
declare function shallowReadonly(obj: T): Readonly;
/**
* Set a property on an object. Adds the new property, triggers change
* notification and intercept it's subsequent access if the property doesn't
* already exist.
*/
declare function set(target: AnyObject, key: any, val: T): T;
/**
* Delete a property and trigger change if necessary.
*/
declare function del(target: AnyObject, key: any): void;
declare const onBeforeMount: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null;
declare const onMounted: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null;
declare const onBeforeUpdate: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null;
declare const onUpdated: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null;
declare const onBeforeUnmount: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null;
declare const onUnmounted: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null;
declare const onErrorCaptured: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null;
declare const onActivated: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null;
declare const onDeactivated: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null;
declare const onServerPrefetch: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null;
declare type WatchEffect = (onInvalidate: InvalidateCbRegistrator) => void;
declare type WatchSource = Ref | ComputedRef | (() => T);
declare type WatchCallback = (value: V, oldValue: OV, onInvalidate: InvalidateCbRegistrator) => any;
declare type MapSources = {
[K in keyof T]: T[K] extends WatchSource ? Immediate extends true ? V | undefined : V : never;
};
declare type MultiWatchSources = (WatchSource | object)[];
interface WatchOptionsBase {
flush?: FlushMode;
}
declare type InvalidateCbRegistrator = (cb: () => void) => void;
declare type FlushMode = 'pre' | 'post' | 'sync';
interface WatchOptions extends WatchOptionsBase {
immediate?: Immediate;
deep?: boolean;
}
interface VueWatcher {
lazy: boolean;
get(): any;
teardown(): void;
run(): void;
value: any;
}
declare type WatchStopHandle = () => void;
declare function watchEffect(effect: WatchEffect, options?: WatchOptionsBase): WatchStopHandle;
declare function watchPostEffect(effect: WatchEffect): WatchStopHandle;
declare function watchSyncEffect(effect: WatchEffect): WatchStopHandle;
declare function watch, Immediate extends Readonly = false>(sources: [...T], cb: WatchCallback, MapSources>, options?: WatchOptions): WatchStopHandle;
declare function watch, Immediate extends Readonly = false>(sources: T, cb: WatchCallback, MapSources>, options?: WatchOptions): WatchStopHandle;
declare function watch = false>(sources: [...T], cb: WatchCallback, MapSources>, options?: WatchOptions): WatchStopHandle;
declare function watch = false>(source: WatchSource, cb: WatchCallback, options?: WatchOptions): WatchStopHandle;
declare function watch