From 26105034da4fcce7ac883c899d781f016559310d Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 8 Nov 2018 00:38:48 +0800 Subject: switch to vuepress --- node_modules/vue/types/index.d.ts | 37 ++++++++ node_modules/vue/types/options.d.ts | 182 ++++++++++++++++++++++++++++++++++++ node_modules/vue/types/plugin.d.ts | 8 ++ node_modules/vue/types/vnode.d.ts | 67 +++++++++++++ node_modules/vue/types/vue.d.ts | 124 ++++++++++++++++++++++++ 5 files changed, 418 insertions(+) create mode 100644 node_modules/vue/types/index.d.ts create mode 100644 node_modules/vue/types/options.d.ts create mode 100644 node_modules/vue/types/plugin.d.ts create mode 100644 node_modules/vue/types/vnode.d.ts create mode 100644 node_modules/vue/types/vue.d.ts (limited to 'node_modules/vue/types') diff --git a/node_modules/vue/types/index.d.ts b/node_modules/vue/types/index.d.ts new file mode 100644 index 00000000..720180d2 --- /dev/null +++ b/node_modules/vue/types/index.d.ts @@ -0,0 +1,37 @@ +import { Vue } from "./vue"; + +export default Vue; + +export { + CreateElement, + VueConstructor +} from "./vue"; + +export { + Component, + AsyncComponent, + ComponentOptions, + FunctionalComponentOptions, + RenderContext, + PropOptions, + ComputedOptions, + WatchHandler, + WatchOptions, + WatchOptionsWithHandler, + DirectiveFunction, + DirectiveOptions +} from "./options"; + +export { + PluginFunction, + PluginObject +} from "./plugin"; + +export { + VNodeChildren, + VNodeChildrenArrayContents, + VNode, + VNodeComponentOptions, + VNodeData, + VNodeDirective +} from "./vnode"; diff --git a/node_modules/vue/types/options.d.ts b/node_modules/vue/types/options.d.ts new file mode 100644 index 00000000..cc58affe --- /dev/null +++ b/node_modules/vue/types/options.d.ts @@ -0,0 +1,182 @@ +import { Vue, CreateElement, CombinedVueInstance } from "./vue"; +import { VNode, VNodeData, VNodeDirective } from "./vnode"; + +type Constructor = { + new (...args: any[]): any; +} + +// we don't support infer props in async component +// N.B. ComponentOptions is contravariant, the default generic should be bottom type +export type Component, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> = + | typeof Vue + | FunctionalComponentOptions + | ComponentOptions + +interface EsModuleComponent { + default: Component +} + +export type AsyncComponent, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> = ( + resolve: (component: Component) => void, + reject: (reason?: any) => void +) => Promise | void; + +/** + * When the `Computed` type parameter on `ComponentOptions` is inferred, + * it should have a property with the return type of every get-accessor. + * Since there isn't a way to query for the return type of a function, we allow TypeScript + * to infer from the shape of `Accessors` and work backwards. + */ +export type Accessors = { + [K in keyof T]: (() => T[K]) | ComputedOptions +} + +type DataDef = Data | ((this: Readonly & V) => Data) +/** + * This type should be used when an array of strings is used for a component's `props` value. + */ +export type ThisTypedComponentOptionsWithArrayProps = + object & + ComponentOptions, V>, Methods, Computed, PropNames[], Record> & + ThisType>>>; + +/** + * This type should be used when an object mapped to `PropOptions` is used for a component's `props` value. + */ +export type ThisTypedComponentOptionsWithRecordProps = + object & + ComponentOptions, Methods, Computed, RecordPropsDefinition, Props> & + ThisType>>; + +type DefaultData = object | ((this: V) => object); +type DefaultProps = Record; +type DefaultMethods = { [key: string]: (this: V, ...args: any[]) => any }; +type DefaultComputed = { [key: string]: any }; +export interface ComponentOptions< + V extends Vue, + Data=DefaultData, + Methods=DefaultMethods, + Computed=DefaultComputed, + PropsDef=PropsDefinition, + Props=DefaultProps> { + data?: Data; + props?: PropsDef; + propsData?: object; + computed?: Accessors; + methods?: Methods; + watch?: Record | WatchHandler | string>; + + el?: Element | string; + template?: string; + // hack is for funcitonal component type inference, should not used in user code + render?(createElement: CreateElement, hack: RenderContext): VNode; + renderError?: (h: () => VNode, err: Error) => VNode; + staticRenderFns?: ((createElement: CreateElement) => VNode)[]; + + beforeCreate?(this: V): void; + created?(): void; + beforeDestroy?(): void; + destroyed?(): void; + beforeMount?(): void; + mounted?(): void; + beforeUpdate?(): void; + updated?(): void; + activated?(): void; + deactivated?(): void; + errorCaptured?(err: Error, vm: Vue, info: string): boolean | void; + + directives?: { [key: string]: DirectiveFunction | DirectiveOptions }; + components?: { [key: string]: Component | AsyncComponent }; + transitions?: { [key: string]: object }; + filters?: { [key: string]: Function }; + + provide?: object | (() => object); + inject?: InjectOptions; + + model?: { + prop?: string; + event?: string; + }; + + parent?: Vue; + mixins?: (ComponentOptions | typeof Vue)[]; + name?: string; + // TODO: support properly inferred 'extends' + extends?: ComponentOptions | typeof Vue; + delimiters?: [string, string]; + comments?: boolean; + inheritAttrs?: boolean; +} + +export interface FunctionalComponentOptions> { + name?: string; + props?: PropDefs; + inject?: InjectOptions; + functional: boolean; + render?(this: undefined, createElement: CreateElement, context: RenderContext): VNode; +} + +export interface RenderContext { + props: Props; + children: VNode[]; + slots(): any; + data: VNodeData; + parent: Vue; + listeners: { [key: string]: Function | Function[] }; + injections: any +} + +export type Prop = { (): T } | { new (...args: any[]): T & object } + +export type PropValidator = PropOptions | Prop | Prop[]; + +export interface PropOptions { + type?: Prop | Prop[]; + required?: boolean; + default?: T | null | undefined | (() => object); + validator?(value: T): boolean; +} + +export type RecordPropsDefinition = { + [K in keyof T]: PropValidator +} +export type ArrayPropsDefinition = (keyof T)[]; +export type PropsDefinition = ArrayPropsDefinition | RecordPropsDefinition; + +export interface ComputedOptions { + get?(): T; + set?(value: T): void; + cache?: boolean; +} + +export type WatchHandler = (val: T, oldVal: T) => void; + +export interface WatchOptions { + deep?: boolean; + immediate?: boolean; +} + +export interface WatchOptionsWithHandler extends WatchOptions { + handler: WatchHandler; +} + +export type DirectiveFunction = ( + el: HTMLElement, + binding: VNodeDirective, + vnode: VNode, + oldVnode: VNode +) => void; + +export interface DirectiveOptions { + bind?: DirectiveFunction; + inserted?: DirectiveFunction; + update?: DirectiveFunction; + componentUpdated?: DirectiveFunction; + unbind?: DirectiveFunction; +} + +export type InjectKey = string | symbol; + +export type InjectOptions = { + [key: string]: InjectKey | { from?: InjectKey, default?: any } +} | string[]; diff --git a/node_modules/vue/types/plugin.d.ts b/node_modules/vue/types/plugin.d.ts new file mode 100644 index 00000000..5741f862 --- /dev/null +++ b/node_modules/vue/types/plugin.d.ts @@ -0,0 +1,8 @@ +import { Vue as _Vue } from "./vue"; + +export type PluginFunction = (Vue: typeof _Vue, options?: T) => void; + +export interface PluginObject { + install: PluginFunction; + [key: string]: any; +} diff --git a/node_modules/vue/types/vnode.d.ts b/node_modules/vue/types/vnode.d.ts new file mode 100644 index 00000000..5754c433 --- /dev/null +++ b/node_modules/vue/types/vnode.d.ts @@ -0,0 +1,67 @@ +import { Vue } from "./vue"; + +export type ScopedSlot = (props: any) => VNodeChildrenArrayContents | string; + +export type VNodeChildren = VNodeChildrenArrayContents | [ScopedSlot] | string; +export interface VNodeChildrenArrayContents extends Array {} + +export interface VNode { + tag?: string; + data?: VNodeData; + children?: VNode[]; + text?: string; + elm?: Node; + ns?: string; + context?: Vue; + key?: string | number; + componentOptions?: VNodeComponentOptions; + componentInstance?: Vue; + parent?: VNode; + raw?: boolean; + isStatic?: boolean; + isRootInsert: boolean; + isComment: boolean; +} + +export interface VNodeComponentOptions { + Ctor: typeof Vue; + propsData?: object; + listeners?: object; + children?: VNodeChildren; + tag?: string; +} + +export interface VNodeData { + key?: string | number; + slot?: string; + scopedSlots?: { [key: string]: ScopedSlot }; + ref?: string; + tag?: string; + staticClass?: string; + class?: any; + staticStyle?: { [key: string]: any }; + style?: object[] | object; + props?: { [key: string]: any }; + attrs?: { [key: string]: any }; + domProps?: { [key: string]: any }; + hook?: { [key: string]: Function }; + on?: { [key: string]: Function | Function[] }; + nativeOn?: { [key: string]: Function | Function[] }; + transition?: object; + show?: boolean; + inlineTemplate?: { + render: Function; + staticRenderFns: Function[]; + }; + directives?: VNodeDirective[]; + keepAlive?: boolean; +} + +export interface VNodeDirective { + readonly name: string; + readonly value: any; + readonly oldValue: any; + readonly expression: any; + readonly arg: string; + readonly modifiers: { [key: string]: boolean }; +} diff --git a/node_modules/vue/types/vue.d.ts b/node_modules/vue/types/vue.d.ts new file mode 100644 index 00000000..e0b29157 --- /dev/null +++ b/node_modules/vue/types/vue.d.ts @@ -0,0 +1,124 @@ +import { + Component, + AsyncComponent, + ComponentOptions, + FunctionalComponentOptions, + WatchOptionsWithHandler, + WatchHandler, + DirectiveOptions, + DirectiveFunction, + RecordPropsDefinition, + ThisTypedComponentOptionsWithArrayProps, + ThisTypedComponentOptionsWithRecordProps, + WatchOptions, +} from "./options"; +import { VNode, VNodeData, VNodeChildren, ScopedSlot } from "./vnode"; +import { PluginFunction, PluginObject } from "./plugin"; + +export interface CreateElement { + (tag?: string | Component | AsyncComponent | (() => Component), children?: VNodeChildren): VNode; + (tag?: string | Component | AsyncComponent | (() => Component), data?: VNodeData, children?: VNodeChildren): VNode; +} + +export interface Vue { + readonly $el: HTMLElement; + readonly $options: ComponentOptions; + readonly $parent: Vue; + readonly $root: Vue; + readonly $children: Vue[]; + readonly $refs: { [key: string]: Vue | Element | Vue[] | Element[] }; + readonly $slots: { [key: string]: VNode[] }; + readonly $scopedSlots: { [key: string]: ScopedSlot }; + readonly $isServer: boolean; + readonly $data: Record; + readonly $props: Record; + readonly $ssrContext: any; + readonly $vnode: VNode; + readonly $attrs: Record; + readonly $listeners: Record; + + $mount(elementOrSelector?: Element | string, hydrating?: boolean): this; + $forceUpdate(): void; + $destroy(): void; + $set: typeof Vue.set; + $delete: typeof Vue.delete; + $watch( + expOrFn: string, + callback: (this: this, n: any, o: any) => void, + options?: WatchOptions + ): (() => void); + $watch( + expOrFn: (this: this) => T, + callback: (this: this, n: T, o: T) => void, + options?: WatchOptions + ): (() => void); + $on(event: string | string[], callback: Function): this; + $once(event: 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; + $createElement: CreateElement; +} + +export type CombinedVueInstance = Data & Methods & Computed & Props & Instance; +export type ExtendedVue = VueConstructor & Vue>; + +export interface VueConfiguration { + 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[] }; +} + +export interface VueConstructor { + new (options?: ThisTypedComponentOptionsWithArrayProps): CombinedVueInstance>; + // ideally, the return type should just contains Props, not Record. But TS requires Base constructors must all have the same return type. + new (options?: ThisTypedComponentOptionsWithRecordProps): CombinedVueInstance>; + new (options?: ComponentOptions): CombinedVueInstance>; + + extend(options?: ThisTypedComponentOptionsWithArrayProps): ExtendedVue>; + extend(options?: ThisTypedComponentOptionsWithRecordProps): ExtendedVue; + extend(definition: FunctionalComponentOptions, PropNames[]>): ExtendedVue>; + extend(definition: FunctionalComponentOptions>): ExtendedVue; + extend(options?: ComponentOptions): ExtendedVue; + + nextTick(callback: () => void, context?: any[]): void; + nextTick(): Promise + set(object: object, key: string, value: T): T; + set(array: T[], key: number, value: T): T; + delete(object: object, key: string): void; + delete(array: T[], key: number): void; + + directive( + id: string, + definition?: DirectiveOptions | DirectiveFunction + ): DirectiveOptions; + filter(id: string, definition?: Function): Function; + + component(id: string): VueConstructor; + component(id: string, constructor: VC): VC; + component(id: string, definition: AsyncComponent): ExtendedVue; + component(id: string, definition?: ThisTypedComponentOptionsWithArrayProps): ExtendedVue>; + component(id: string, definition?: ThisTypedComponentOptionsWithRecordProps): ExtendedVue; + component(id: string, definition: FunctionalComponentOptions, PropNames[]>): ExtendedVue>; + component(id: string, definition: FunctionalComponentOptions>): ExtendedVue; + component(id: string, definition?: ComponentOptions): ExtendedVue; + + use(plugin: PluginObject | PluginFunction, options?: T): void; + use(plugin: PluginObject | PluginFunction, ...options: any[]): void; + mixin(mixin: VueConstructor | ComponentOptions): void; + compile(template: string): { + render(createElement: typeof Vue.prototype.$createElement): VNode; + staticRenderFns: (() => VNode)[]; + }; + + config: VueConfiguration; +} + +export const Vue: VueConstructor; -- cgit v1.2.3