2016-08-23 19:01:30 +00:00
|
|
|
import {
|
2016-09-30 17:57:38 +00:00
|
|
|
Component,
|
|
|
|
AsyncComponent,
|
2016-08-23 19:01:30 +00:00
|
|
|
ComponentOptions,
|
2016-09-05 10:53:34 +00:00
|
|
|
FunctionalComponentOptions,
|
2017-10-06 18:45:14 +00:00
|
|
|
WatchOptionsWithHandler,
|
2016-08-23 19:01:30 +00:00
|
|
|
WatchHandler,
|
|
|
|
DirectiveOptions,
|
2017-10-06 18:45:14 +00:00
|
|
|
DirectiveFunction,
|
|
|
|
RecordPropsDefinition,
|
|
|
|
ThisTypedComponentOptionsWithArrayProps,
|
|
|
|
ThisTypedComponentOptionsWithRecordProps,
|
2022-05-27 09:26:55 +00:00
|
|
|
WatchOptions
|
|
|
|
} from './options'
|
|
|
|
import { VNode, VNodeData, VNodeChildren, NormalizedScopedSlot } from './vnode'
|
|
|
|
import { PluginFunction, PluginObject } from './plugin'
|
2016-08-23 19:01:30 +00:00
|
|
|
|
2017-10-06 18:45:14 +00:00
|
|
|
export interface CreateElement {
|
2022-05-27 09:26:55 +00:00
|
|
|
(
|
|
|
|
tag?:
|
|
|
|
| string
|
|
|
|
| Component<any, any, any, any>
|
|
|
|
| AsyncComponent<any, any, any, any>
|
|
|
|
| (() => Component),
|
|
|
|
children?: VNodeChildren
|
|
|
|
): VNode
|
|
|
|
(
|
|
|
|
tag?:
|
|
|
|
| string
|
|
|
|
| Component<any, any, any, any>
|
|
|
|
| AsyncComponent<any, any, any, any>
|
|
|
|
| (() => Component),
|
|
|
|
data?: VNodeData,
|
|
|
|
children?: VNodeChildren
|
|
|
|
): VNode
|
2016-10-08 18:15:36 +00:00
|
|
|
}
|
|
|
|
|
2017-10-06 18:45:14 +00:00
|
|
|
export interface Vue {
|
2022-05-27 09:26:55 +00:00
|
|
|
readonly $el: Element
|
|
|
|
readonly $options: ComponentOptions<Vue>
|
|
|
|
readonly $parent: Vue
|
|
|
|
readonly $root: Vue
|
|
|
|
readonly $children: Vue[]
|
|
|
|
readonly $refs: {
|
|
|
|
[key: string]: Vue | Element | (Vue | Element)[] | undefined
|
|
|
|
}
|
|
|
|
readonly $slots: { [key: string]: VNode[] | undefined }
|
|
|
|
readonly $scopedSlots: { [key: string]: NormalizedScopedSlot | undefined }
|
|
|
|
readonly $isServer: boolean
|
|
|
|
readonly $data: Record<string, any>
|
|
|
|
readonly $props: Record<string, any>
|
|
|
|
readonly $ssrContext: any
|
|
|
|
readonly $vnode: VNode
|
|
|
|
readonly $attrs: Record<string, string>
|
|
|
|
readonly $listeners: Record<string, Function | Function[]>
|
|
|
|
|
|
|
|
$mount(elementOrSelector?: Element | string, hydrating?: boolean): this
|
|
|
|
$forceUpdate(): void
|
|
|
|
$destroy(): void
|
|
|
|
$set: typeof Vue.set
|
|
|
|
$delete: typeof Vue.delete
|
2016-08-23 19:01:30 +00:00
|
|
|
$watch(
|
2017-02-10 07:06:24 +00:00
|
|
|
expOrFn: string,
|
2017-10-06 18:45:14 +00:00
|
|
|
callback: (this: this, n: any, o: any) => void,
|
2017-02-10 07:06:24 +00:00
|
|
|
options?: WatchOptions
|
2022-05-27 09:26:55 +00:00
|
|
|
): () => void
|
2017-02-10 07:06:24 +00:00
|
|
|
$watch<T>(
|
2017-02-11 11:25:17 +00:00
|
|
|
expOrFn: (this: this) => T,
|
2017-10-06 18:45:14 +00:00
|
|
|
callback: (this: this, n: T, o: T) => void,
|
2016-08-23 19:01:30 +00:00
|
|
|
options?: WatchOptions
|
2022-05-27 09:26:55 +00:00
|
|
|
): () => void
|
|
|
|
$on(event: string | string[], callback: Function): this
|
|
|
|
$once(event: string | string[], callback: Function): this
|
|
|
|
$off(event?: string | string[], callback?: Function): this
|
|
|
|
$emit(event: string, ...args: any[]): this
|
|
|
|
$nextTick(callback: (this: this) => void): void
|
|
|
|
$nextTick(): Promise<void>
|
|
|
|
$createElement: CreateElement
|
2017-10-06 18:45:14 +00:00
|
|
|
}
|
|
|
|
|
2022-05-27 09:26:55 +00:00
|
|
|
export type CombinedVueInstance<
|
|
|
|
Instance extends Vue,
|
|
|
|
Data,
|
|
|
|
Methods,
|
|
|
|
Computed,
|
|
|
|
Props,
|
|
|
|
SetupBindings
|
|
|
|
> = Data & Methods & Computed & Props & Instance & SetupBindings
|
|
|
|
|
|
|
|
export type ExtendedVue<
|
|
|
|
Instance extends Vue,
|
|
|
|
Data,
|
|
|
|
Methods,
|
|
|
|
Computed,
|
|
|
|
Props,
|
|
|
|
SetupBindings
|
|
|
|
> = VueConstructor<
|
|
|
|
CombinedVueInstance<Instance, Data, Methods, Computed, Props, SetupBindings> &
|
|
|
|
Vue
|
|
|
|
>
|
2017-10-06 18:45:14 +00:00
|
|
|
|
2017-12-19 14:34:35 +00:00
|
|
|
export interface VueConfiguration {
|
2022-05-27 09:26:55 +00:00
|
|
|
silent: boolean
|
|
|
|
optionMergeStrategies: any
|
|
|
|
devtools: boolean
|
|
|
|
productionTip: boolean
|
|
|
|
performance: boolean
|
|
|
|
errorHandler(err: Error, vm: Vue, info: string): void
|
|
|
|
warnHandler(msg: string, vm: Vue, trace: string): void
|
|
|
|
ignoredElements: (string | RegExp)[]
|
|
|
|
keyCodes: { [key: string]: number | number[] }
|
|
|
|
async: boolean
|
2017-12-19 14:34:35 +00:00
|
|
|
}
|
|
|
|
|
2017-10-06 18:45:14 +00:00
|
|
|
export interface VueConstructor<V extends Vue = Vue> {
|
2022-05-27 09:26:55 +00:00
|
|
|
/**
|
|
|
|
* new with array props
|
|
|
|
*/
|
|
|
|
new <
|
|
|
|
Data = object,
|
|
|
|
Methods = object,
|
|
|
|
Computed = object,
|
|
|
|
PropNames extends string = never,
|
|
|
|
SetupBindings = {}
|
|
|
|
>(
|
|
|
|
options?: ThisTypedComponentOptionsWithArrayProps<
|
|
|
|
V,
|
|
|
|
Data,
|
|
|
|
Methods,
|
|
|
|
Computed,
|
|
|
|
PropNames,
|
|
|
|
SetupBindings
|
|
|
|
>
|
|
|
|
): CombinedVueInstance<
|
|
|
|
V,
|
|
|
|
Data,
|
|
|
|
Methods,
|
|
|
|
Computed,
|
|
|
|
Record<PropNames, any>,
|
|
|
|
SetupBindings
|
|
|
|
>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* new with object props
|
|
|
|
* ideally, the return type should just contain Props,
|
|
|
|
* not Record<keyof Props, any>. But TS requires to have Base constructors
|
|
|
|
* with the same return type.
|
|
|
|
*/
|
|
|
|
new <
|
|
|
|
Data = object,
|
|
|
|
Methods = object,
|
|
|
|
Computed = object,
|
|
|
|
Props = object,
|
|
|
|
SetupBindings = {}
|
|
|
|
>(
|
|
|
|
options?: ThisTypedComponentOptionsWithRecordProps<
|
|
|
|
V,
|
|
|
|
Data,
|
|
|
|
Methods,
|
|
|
|
Computed,
|
|
|
|
Props,
|
|
|
|
SetupBindings
|
|
|
|
>
|
|
|
|
): CombinedVueInstance<
|
|
|
|
V,
|
|
|
|
Data,
|
|
|
|
Methods,
|
|
|
|
Computed,
|
|
|
|
Record<keyof Props, any>,
|
|
|
|
SetupBindings
|
|
|
|
>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* new with no props
|
|
|
|
*/
|
|
|
|
new (options?: ComponentOptions<V>): CombinedVueInstance<
|
|
|
|
V,
|
|
|
|
object,
|
|
|
|
object,
|
|
|
|
object,
|
|
|
|
Record<keyof object, any>,
|
|
|
|
{}
|
|
|
|
>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* extend with array props
|
|
|
|
*/
|
|
|
|
extend<
|
|
|
|
Data,
|
|
|
|
Methods,
|
|
|
|
Computed,
|
|
|
|
PropNames extends string = never,
|
|
|
|
SetupBindings = {}
|
|
|
|
>(
|
|
|
|
options?: ThisTypedComponentOptionsWithArrayProps<
|
|
|
|
V,
|
|
|
|
Data,
|
|
|
|
Methods,
|
|
|
|
Computed,
|
|
|
|
PropNames,
|
|
|
|
SetupBindings
|
|
|
|
>
|
|
|
|
): ExtendedVue<
|
|
|
|
V,
|
|
|
|
Data,
|
|
|
|
Methods,
|
|
|
|
Computed,
|
|
|
|
Record<PropNames, any>,
|
|
|
|
SetupBindings
|
|
|
|
>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* extend with object props
|
|
|
|
*/
|
|
|
|
extend<Data, Methods, Computed, Props, SetupBindings = {}>(
|
|
|
|
options?: ThisTypedComponentOptionsWithRecordProps<
|
|
|
|
V,
|
|
|
|
Data,
|
|
|
|
Methods,
|
|
|
|
Computed,
|
|
|
|
Props,
|
|
|
|
SetupBindings
|
|
|
|
>
|
|
|
|
): ExtendedVue<V, Data, Methods, Computed, Props, SetupBindings>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* extend with functional + array props
|
|
|
|
*/
|
|
|
|
extend<PropNames extends string = never>(
|
|
|
|
definition: FunctionalComponentOptions<Record<PropNames, any>, PropNames[]>
|
|
|
|
): ExtendedVue<V, {}, {}, {}, Record<PropNames, any>, {}>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* extend with functional + object props
|
|
|
|
*/
|
|
|
|
extend<Props>(
|
|
|
|
definition: FunctionalComponentOptions<Props, RecordPropsDefinition<Props>>
|
|
|
|
): ExtendedVue<V, {}, {}, {}, Props, {}>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* extend with no props
|
|
|
|
*/
|
|
|
|
extend(options?: ComponentOptions<V>): ExtendedVue<V, {}, {}, {}, {}, {}>
|
|
|
|
|
|
|
|
nextTick<T>(callback: (this: T) => void, context?: T): void
|
2017-10-06 18:45:14 +00:00
|
|
|
nextTick(): Promise<void>
|
2022-05-27 09:26:55 +00:00
|
|
|
set<T>(object: object, key: string | number, value: T): T
|
|
|
|
set<T>(array: T[], key: number, value: T): T
|
|
|
|
delete(object: object, key: string | number): void
|
|
|
|
delete<T>(array: T[], key: number): void
|
2017-10-06 18:45:14 +00:00
|
|
|
|
|
|
|
directive(
|
|
|
|
id: string,
|
|
|
|
definition?: DirectiveOptions | DirectiveFunction
|
2022-05-27 09:26:55 +00:00
|
|
|
): DirectiveOptions
|
|
|
|
filter(id: string, definition?: Function): Function
|
|
|
|
|
|
|
|
component(id: string): VueConstructor
|
|
|
|
component<VC extends VueConstructor>(id: string, constructor: VC): VC
|
|
|
|
component<Data, Methods, Computed, Props, SetupBindings>(
|
|
|
|
id: string,
|
|
|
|
definition: AsyncComponent<Data, Methods, Computed, Props>
|
|
|
|
): ExtendedVue<V, Data, Methods, Computed, Props, SetupBindings>
|
|
|
|
component<
|
|
|
|
Data,
|
|
|
|
Methods,
|
|
|
|
Computed,
|
|
|
|
PropNames extends string = never,
|
|
|
|
SetupBindings = {}
|
|
|
|
>(
|
|
|
|
id: string,
|
|
|
|
definition?: ThisTypedComponentOptionsWithArrayProps<
|
|
|
|
V,
|
|
|
|
Data,
|
|
|
|
Methods,
|
|
|
|
Computed,
|
|
|
|
PropNames,
|
|
|
|
SetupBindings
|
|
|
|
>
|
|
|
|
): ExtendedVue<
|
|
|
|
V,
|
|
|
|
Data,
|
|
|
|
Methods,
|
|
|
|
Computed,
|
|
|
|
Record<PropNames, any>,
|
|
|
|
SetupBindings
|
|
|
|
>
|
|
|
|
component<Data, Methods, Computed, Props, SetupBindings>(
|
|
|
|
id: string,
|
|
|
|
definition?: ThisTypedComponentOptionsWithRecordProps<
|
|
|
|
V,
|
|
|
|
Data,
|
|
|
|
Methods,
|
|
|
|
Computed,
|
|
|
|
Props,
|
|
|
|
SetupBindings
|
|
|
|
>
|
|
|
|
): ExtendedVue<V, Data, Methods, Computed, Props, SetupBindings>
|
|
|
|
component<PropNames extends string>(
|
|
|
|
id: string,
|
|
|
|
definition: FunctionalComponentOptions<Record<PropNames, any>, PropNames[]>
|
|
|
|
): ExtendedVue<V, {}, {}, {}, Record<PropNames, any>, {}>
|
|
|
|
component<Props>(
|
|
|
|
id: string,
|
|
|
|
definition: FunctionalComponentOptions<Props, RecordPropsDefinition<Props>>
|
|
|
|
): ExtendedVue<V, {}, {}, {}, Props, {}>
|
|
|
|
component(
|
|
|
|
id: string,
|
|
|
|
definition?: ComponentOptions<V>
|
|
|
|
): ExtendedVue<V, {}, {}, {}, {}, {}>
|
|
|
|
|
|
|
|
use<T>(
|
|
|
|
plugin: PluginObject<T> | PluginFunction<T>,
|
|
|
|
options?: T
|
|
|
|
): VueConstructor<V>
|
|
|
|
use(
|
|
|
|
plugin: PluginObject<any> | PluginFunction<any>,
|
|
|
|
...options: any[]
|
|
|
|
): VueConstructor<V>
|
|
|
|
mixin(mixin: VueConstructor | ComponentOptions<Vue>): VueConstructor<V>
|
2017-10-06 18:45:14 +00:00
|
|
|
compile(template: string): {
|
2022-05-27 09:26:55 +00:00
|
|
|
render(createElement: typeof Vue.prototype.$createElement): VNode
|
|
|
|
staticRenderFns: (() => VNode)[]
|
|
|
|
}
|
2017-10-06 18:45:14 +00:00
|
|
|
|
2022-05-27 09:26:55 +00:00
|
|
|
observable<T>(obj: T): T
|
2019-01-11 03:44:55 +00:00
|
|
|
|
2021-03-30 09:46:53 +00:00
|
|
|
util: {
|
2022-05-27 09:26:55 +00:00
|
|
|
warn(msg: string, vm?: InstanceType<VueConstructor>): void
|
|
|
|
}
|
2021-03-30 09:46:53 +00:00
|
|
|
|
2022-05-27 09:26:55 +00:00
|
|
|
config: VueConfiguration
|
|
|
|
version: string
|
2016-08-23 19:01:30 +00:00
|
|
|
}
|
2017-10-06 18:45:14 +00:00
|
|
|
|
2022-05-27 09:26:55 +00:00
|
|
|
export const Vue: VueConstructor
|