2016-10-08 18:15:36 +00:00
|
|
|
import { Vue, CreateElement } from "./vue";
|
2016-09-06 13:28:17 +00:00
|
|
|
import { VNode, VNodeData, VNodeDirective } from "./vnode";
|
2016-08-23 19:01:30 +00:00
|
|
|
|
|
|
|
type Constructor = {
|
|
|
|
new (...args: any[]): any;
|
|
|
|
}
|
|
|
|
|
2016-09-30 17:57:38 +00:00
|
|
|
export type Component = typeof Vue | ComponentOptions<Vue> | FunctionalComponentOptions;
|
|
|
|
export type AsyncComponent = (
|
|
|
|
resolve: (component: Component) => void,
|
|
|
|
reject: (reason?: any) => void
|
|
|
|
) => Promise<Component> | Component | void;
|
|
|
|
|
2016-09-13 23:59:14 +00:00
|
|
|
export interface ComponentOptions<V extends Vue> {
|
|
|
|
data?: Object | ((this: V) => Object);
|
2016-08-23 19:01:30 +00:00
|
|
|
props?: string[] | { [key: string]: PropOptions | Constructor | Constructor[] };
|
|
|
|
propsData?: Object;
|
2016-09-13 23:59:14 +00:00
|
|
|
computed?: { [key: string]: ((this: V) => any) | ComputedOptions<V> };
|
2016-10-08 18:15:36 +00:00
|
|
|
methods?: { [key: string]: (this: V, ...args: any[]) => any };
|
2016-09-13 23:59:14 +00:00
|
|
|
watch?: { [key: string]: ({ handler: WatchHandler<V> } & WatchOptions) | WatchHandler<V> | string };
|
2016-08-23 19:01:30 +00:00
|
|
|
|
|
|
|
el?: Element | String;
|
|
|
|
template?: string;
|
2016-10-08 18:15:36 +00:00
|
|
|
render?(this: V, createElement: CreateElement): VNode;
|
|
|
|
staticRenderFns?: ((createElement: CreateElement) => VNode)[];
|
2016-08-23 19:01:30 +00:00
|
|
|
|
2016-09-13 23:59:14 +00:00
|
|
|
beforeCreate?(this: V): void;
|
|
|
|
created?(this: V): void;
|
|
|
|
beforeDestroy?(this: V): void;
|
|
|
|
destroyed?(this: V): void;
|
|
|
|
beforeMount?(this: V): void;
|
|
|
|
mounted?(this: V): void;
|
|
|
|
beforeUpdate?(this: V): void;
|
|
|
|
updated?(this: V): void;
|
2016-08-23 19:01:30 +00:00
|
|
|
|
|
|
|
directives?: { [key: string]: DirectiveOptions | DirectiveFunction };
|
2016-09-30 17:57:38 +00:00
|
|
|
components?: { [key: string]: Component | AsyncComponent };
|
2016-08-23 19:01:30 +00:00
|
|
|
transitions?: { [key: string]: Object };
|
|
|
|
filters?: { [key: string]: Function };
|
|
|
|
|
|
|
|
parent?: Vue;
|
2016-09-13 23:59:14 +00:00
|
|
|
mixins?: (ComponentOptions<Vue> | typeof Vue)[];
|
2016-08-23 19:01:30 +00:00
|
|
|
name?: string;
|
2016-09-13 23:59:14 +00:00
|
|
|
extends?: ComponentOptions<Vue> | typeof Vue;
|
2016-08-23 19:01:30 +00:00
|
|
|
delimiters?: [string, string];
|
|
|
|
}
|
|
|
|
|
2016-09-05 10:53:34 +00:00
|
|
|
export interface FunctionalComponentOptions {
|
|
|
|
props?: string[] | { [key: string]: PropOptions | Constructor | Constructor[] };
|
|
|
|
functional: boolean;
|
2016-10-08 18:15:36 +00:00
|
|
|
render(this: never, createElement: CreateElement, context: RenderContext): VNode;
|
2016-09-05 10:53:34 +00:00
|
|
|
name?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface RenderContext {
|
|
|
|
props: any;
|
|
|
|
children: VNode[];
|
2016-11-03 17:07:07 +00:00
|
|
|
slots(): any;
|
2016-09-05 10:53:34 +00:00
|
|
|
data: VNodeData;
|
|
|
|
parent: Vue;
|
|
|
|
}
|
|
|
|
|
2016-08-23 19:01:30 +00:00
|
|
|
export interface PropOptions {
|
|
|
|
type?: Constructor | Constructor[] | null;
|
|
|
|
required?: boolean;
|
|
|
|
default?: any;
|
|
|
|
validator?(value: any): boolean;
|
|
|
|
}
|
|
|
|
|
2016-09-13 23:59:14 +00:00
|
|
|
export interface ComputedOptions<V> {
|
|
|
|
get?(this: V): any;
|
|
|
|
set?(this: V, value: any): void;
|
2016-08-23 19:01:30 +00:00
|
|
|
cache?: boolean;
|
|
|
|
}
|
|
|
|
|
2016-09-13 23:59:14 +00:00
|
|
|
export type WatchHandler<V> = (this: V, val: any, oldVal: any) => void;
|
2016-08-23 19:01:30 +00:00
|
|
|
|
|
|
|
export interface WatchOptions {
|
|
|
|
deep?: boolean;
|
|
|
|
immediate?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type DirectiveFunction = (
|
|
|
|
el: HTMLElement,
|
|
|
|
binding: VNodeDirective,
|
|
|
|
vnode: VNode,
|
|
|
|
oldVnode: VNode
|
|
|
|
) => void;
|
|
|
|
|
|
|
|
export interface DirectiveOptions {
|
|
|
|
bind?: DirectiveFunction;
|
2016-09-16 16:40:13 +00:00
|
|
|
inserted?: DirectiveFunction;
|
2016-08-23 19:01:30 +00:00
|
|
|
update?: DirectiveFunction;
|
|
|
|
componentUpdated?: DirectiveFunction;
|
|
|
|
unbind?: DirectiveFunction;
|
|
|
|
}
|