diff --git a/types/index.d.ts b/types/index.d.ts index 58ceb209e..a792a1b03 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,12 +1,9 @@ -import { Vue } from "./vue"; -import "./umd"; +import { Vue } from './vue' +import './umd' -export default Vue; +export default Vue -export { - CreateElement, - VueConstructor -} from "./vue"; +export { CreateElement, VueConstructor } from './vue' export { Component, @@ -22,12 +19,9 @@ export { WatchOptionsWithHandler, DirectiveFunction, DirectiveOptions -} from "./options"; +} from './options' -export { - PluginFunction, - PluginObject -} from "./plugin"; +export { PluginFunction, PluginObject } from './plugin' export { VNodeChildren, @@ -36,4 +30,6 @@ export { VNodeComponentOptions, VNodeData, VNodeDirective -} from "./vnode"; +} from './vnode' + +export { h, getCurrentInstance } from './v3' diff --git a/types/options.d.ts b/types/options.d.ts index ff266052f..3701acb33 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -1,37 +1,73 @@ -import { Vue, CreateElement, CombinedVueInstance } from "./vue"; -import { VNode, VNodeData, VNodeDirective, NormalizedScopedSlot } from "./vnode"; +import { Vue, CreateElement, CombinedVueInstance } from './vue' +import { VNode, VNodeData, VNodeDirective, NormalizedScopedSlot } from './vnode' +import { SetupContext } from './v3' type Constructor = { - new (...args: any[]): any; + 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> = +export type Component< + Data = DefaultData, + Methods = DefaultMethods, + Computed = DefaultComputed, + Props = DefaultProps, + SetupBindings = {} +> = | typeof Vue | FunctionalComponentOptions - | ComponentOptions + | ComponentOptions type EsModule = T | { default: T } -type ImportedComponent, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> - = EsModule> +type ImportedComponent< + Data = DefaultData, + Methods = DefaultMethods, + Computed = DefaultComputed, + Props = DefaultProps, + SetupBindings = {} +> = EsModule> -export type AsyncComponent, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> - = AsyncComponentPromise - | AsyncComponentFactory +export type AsyncComponent< + Data = DefaultData, + Methods = DefaultMethods, + Computed = DefaultComputed, + Props = DefaultProps, + SetupBindings = {} +> = + | AsyncComponentPromise + | AsyncComponentFactory -export type AsyncComponentPromise, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> = ( - resolve: (component: Component) => void, +export type AsyncComponentPromise< + Data = DefaultData, + Methods = DefaultMethods, + Computed = DefaultComputed, + Props = DefaultProps, + SetupBindings = {} +> = ( + resolve: ( + component: Component + ) => void, reject: (reason?: any) => void -) => Promise> | void; +) => Promise< + ImportedComponent +> | void -export type AsyncComponentFactory, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> = () => { - component: Promise>; - loading?: ImportedComponent; - error?: ImportedComponent; - delay?: number; - timeout?: number; +export type AsyncComponentFactory< + Data = DefaultData, + Methods = DefaultMethods, + Computed = DefaultComputed, + Props = DefaultProps, + SetupBindings = {} +> = () => { + component: Promise< + ImportedComponent + > + loading?: ImportedComponent + error?: ImportedComponent + delay?: number + timeout?: number } /** @@ -48,141 +84,212 @@ 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>>>; +export type ThisTypedComponentOptionsWithArrayProps< + V extends Vue, + Data, + Methods, + Computed, + PropNames extends string, + SetupBindings +> = object & + ComponentOptions< + V, + DataDef, V>, + Methods, + Computed, + PropNames[], + Record, + SetupBindings + > & + ThisType< + CombinedVueInstance< + V, + Data, + Methods, + Computed, + Readonly>, + SetupBindings + > + > /** * 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>>; +export type ThisTypedComponentOptionsWithRecordProps< + V extends Vue, + Data, + Methods, + Computed, + Props, + SetupBindings +> = object & + ComponentOptions< + V, + DataDef, + Methods, + Computed, + RecordPropsDefinition, + Props, + SetupBindings + > & + ThisType< + CombinedVueInstance< + V, + Data, + Methods, + Computed, + Readonly, + SetupBindings + > + > + +type DefaultData = object | ((this: V) => object) +type DefaultProps = Record +type DefaultMethods = { [key: string]: (this: V, ...args: any[]) => any } +type DefaultComputed = { [key: string]: any } -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>; + Data = DefaultData, + Methods = DefaultMethods, + Computed = DefaultComputed, + PropsDef = PropsDefinition, + Props = DefaultProps, + RawBindings = {} +> { + data?: Data + props?: PropsDef + propsData?: object + computed?: Accessors + methods?: Methods + watch?: Record | WatchHandler> - el?: Element | string; - template?: string; + setup?: ( + this: void, + props: Props, + ctx: SetupContext + ) => Promise | RawBindings | ((h: CreateElement) => VNode) | void + + el?: Element | string + template?: string // hack is for functional component type inference, should not be used in user code - render?(createElement: CreateElement, hack: RenderContext): VNode; - renderError?(createElement: CreateElement, err: Error): VNode; - staticRenderFns?: ((createElement: CreateElement) => VNode)[]; + render?(createElement: CreateElement, hack: RenderContext): VNode + renderError?(createElement: CreateElement, 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; - serverPrefetch?(this: V): Promise; + 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 + serverPrefetch?(this: V): Promise - directives?: { [key: string]: DirectiveFunction | DirectiveOptions }; - components?: { [key: string]: Component | AsyncComponent }; - transitions?: { [key: string]: object }; - filters?: { [key: string]: Function }; + directives?: { [key: string]: DirectiveFunction | DirectiveOptions } + components?: { + [key: string]: + | Component + | AsyncComponent + } + transitions?: { [key: string]: object } + filters?: { [key: string]: Function } - provide?: object | (() => object); - inject?: InjectOptions; + provide?: object | (() => object) + inject?: InjectOptions model?: { - prop?: string; - event?: string; - }; + prop?: string + event?: string + } - parent?: Vue; - mixins?: (ComponentOptions | typeof Vue)[]; - name?: 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; + extends?: ComponentOptions | typeof Vue + delimiters?: [string, string] + comments?: boolean + inheritAttrs?: boolean } -export interface FunctionalComponentOptions> { - name?: string; - props?: PropDefs; +export interface FunctionalComponentOptions< + Props = DefaultProps, + PropDefs = PropsDefinition +> { + name?: string + props?: PropDefs model?: { - prop?: string; - event?: string; - }; - inject?: InjectOptions; - functional: boolean; - render?(this: undefined, createElement: CreateElement, context: RenderContext): VNode | VNode[]; + prop?: string + event?: string + } + inject?: InjectOptions + functional: boolean + render?( + this: undefined, + createElement: CreateElement, + context: RenderContext + ): VNode | VNode[] } -export interface RenderContext { - props: Props; - children: VNode[]; - slots(): any; - data: VNodeData; - parent: Vue; - listeners: { [key: string]: Function | Function[] }; - scopedSlots: { [key: string]: NormalizedScopedSlot }; +export interface RenderContext { + props: Props + children: VNode[] + slots(): any + data: VNodeData + parent: Vue + listeners: { [key: string]: Function | Function[] } + scopedSlots: { [key: string]: NormalizedScopedSlot } injections: any } -export type Prop = { (): T } | { new(...args: never[]): T & object } | { new(...args: string[]): Function } +export type Prop = + | { (): T } + | { new (...args: never[]): T & object } + | { new (...args: string[]): Function } -export type PropType = Prop | Prop[]; +export type PropType = Prop | Prop[] -export type PropValidator = PropOptions | PropType; +export type PropValidator = PropOptions | PropType -export interface PropOptions { - type?: PropType; - required?: boolean; - default?: T | null | undefined | (() => T | null | undefined); - validator?(value: T): boolean; +export interface PropOptions { + type?: PropType + required?: boolean + default?: T | null | undefined | (() => T | null | undefined) + validator?(value: T): boolean } export type RecordPropsDefinition = { [K in keyof T]: PropValidator } -export type ArrayPropsDefinition = (keyof T)[]; -export type PropsDefinition = ArrayPropsDefinition | RecordPropsDefinition; +export type ArrayPropsDefinition = (keyof T)[] +export type PropsDefinition = + | ArrayPropsDefinition + | RecordPropsDefinition export interface ComputedOptions { - get?(): T; - set?(value: T): void; - cache?: boolean; + get?(): T + set?(value: T): void + cache?: boolean } -export type WatchHandler = string | ((val: T, oldVal: T) => void); +export type WatchHandler = string | ((val: T, oldVal: T) => void) export interface WatchOptions { - deep?: boolean; - immediate?: boolean; + deep?: boolean + immediate?: boolean } export interface WatchOptionsWithHandler extends WatchOptions { - handler: WatchHandler; + handler: WatchHandler } export interface DirectiveBinding extends Readonly { - readonly modifiers: { [key: string]: boolean }; + readonly modifiers: { [key: string]: boolean } } export type DirectiveFunction = ( @@ -190,18 +297,20 @@ export type DirectiveFunction = ( binding: DirectiveBinding, vnode: VNode, oldVnode: VNode -) => void; +) => void export interface DirectiveOptions { - bind?: DirectiveFunction; - inserted?: DirectiveFunction; - update?: DirectiveFunction; - componentUpdated?: DirectiveFunction; - unbind?: DirectiveFunction; + bind?: DirectiveFunction + inserted?: DirectiveFunction + update?: DirectiveFunction + componentUpdated?: DirectiveFunction + unbind?: DirectiveFunction } -export type InjectKey = string | symbol; +export type InjectKey = string | symbol -export type InjectOptions = { - [key: string]: InjectKey | { from?: InjectKey, default?: any } -} | string[]; +export type InjectOptions = + | { + [key: string]: InjectKey | { from?: InjectKey; default?: any } + } + | string[] diff --git a/types/plugin.d.ts b/types/plugin.d.ts index 5741f862c..8ebdfae90 100644 --- a/types/plugin.d.ts +++ b/types/plugin.d.ts @@ -1,8 +1,8 @@ -import { Vue as _Vue } from "./vue"; +import { Vue as _Vue } from './vue' -export type PluginFunction = (Vue: typeof _Vue, options?: T) => void; +export type PluginFunction = (Vue: typeof _Vue, options?: T) => void export interface PluginObject { - install: PluginFunction; - [key: string]: any; + install: PluginFunction + [key: string]: any } diff --git a/types/test/async-component-test.ts b/types/test/async-component-test.ts index baa50c4b9..d139157b5 100644 --- a/types/test/async-component-test.ts +++ b/types/test/async-component-test.ts @@ -1,8 +1,8 @@ -import Vue, { AsyncComponent, Component } from "../index"; +import Vue, { AsyncComponent, Component } from '../index' const a: AsyncComponent = () => ({ component: new Promise((res, rej) => { - res({ template: "" }) + res({ template: '' }) }) }) @@ -10,14 +10,14 @@ const b: AsyncComponent = () => ({ // @ts-expect-error component has to be a Promise that resolves to a component component: () => new Promise((res, rej) => { - res({ template: "" }) + res({ template: '' }) }) }) const c: AsyncComponent = () => new Promise((res, rej) => { res({ - template: "" + template: '' }) }) @@ -25,7 +25,7 @@ const d: AsyncComponent = () => new Promise<{ default: Component }>((res, rej) => { res({ default: { - template: "" + template: '' } }) }) @@ -34,11 +34,11 @@ const e: AsyncComponent = () => ({ component: new Promise<{ default: Component }>((res, rej) => { res({ default: { - template: "" + template: '' } }) }) }) // Test that Vue.component accepts any AsyncComponent -Vue.component("async-compponent1", a) +Vue.component('async-compponent1', a) diff --git a/types/test/augmentation-test.ts b/types/test/augmentation-test.ts index bb7767210..77c616f18 100644 --- a/types/test/augmentation-test.ts +++ b/types/test/augmentation-test.ts @@ -1,46 +1,46 @@ -import Vue from "../index"; +import Vue from '../index' -declare module "../vue" { +declare module '../vue' { // add instance property and method interface Vue { - $instanceProperty: string; - $instanceMethod(): void; + $instanceProperty: string + $instanceMethod(): void } // add static property and method interface VueConstructor { - staticProperty: string; - staticMethod(): void; + staticProperty: string + staticMethod(): void } } // augment ComponentOptions -declare module "../options" { +declare module '../options' { interface ComponentOptions { - foo?: string; + foo?: string } } const vm = new Vue({ - props: ["bar"], + props: ['bar'], data: { a: true }, - foo: "foo", + foo: 'foo', methods: { foo() { - this.a = false; + this.a = false } }, computed: { BAR(): string { - return this.bar.toUpperCase(); + return this.bar.toUpperCase() } } -}); +}) -vm.$instanceProperty; -vm.$instanceMethod(); +vm.$instanceProperty +vm.$instanceMethod() -Vue.staticProperty; -Vue.staticMethod(); +Vue.staticProperty +Vue.staticMethod() diff --git a/types/test/options-test.ts b/types/test/options-test.ts index cb8fa2e3f..49deeb9ef 100644 --- a/types/test/options-test.ts +++ b/types/test/options-test.ts @@ -1,9 +1,9 @@ -import Vue, { PropType, VNode } from "../index"; -import { ComponentOptions, Component } from "../index"; -import { CreateElement } from "../vue"; +import Vue, { PropType, VNode } from '../index' +import { ComponentOptions, Component } from '../index' +import { CreateElement } from '../vue' interface MyComponent extends Vue { - a: number; + a: number } const option: ComponentOptions = { @@ -20,10 +20,10 @@ const componentType: Component = option Vue.component('sub-component', { components: { - a: Vue.component(""), + a: Vue.component(''), b: {} } -}); +}) Vue.component('prop-component', { props: { @@ -31,7 +31,7 @@ Vue.component('prop-component', { name: { type: String, default: '0', - required: true, + required: true } }, data() { @@ -40,7 +40,7 @@ Vue.component('prop-component', { capName: this.name.toUpperCase() } } -}); +}) Vue.component('string-prop', { props: ['size', 'name'], @@ -50,7 +50,7 @@ Vue.component('string-prop', { capName: this.name.isany } } -}); +}) class User { private u = 1 @@ -60,15 +60,15 @@ class Cat { } interface IUser { - foo: string, + foo: string bar: number } interface ICat { - foo: any, + foo: any bar: object } -type ConfirmCallback = (confirm: boolean) => void; +type ConfirmCallback = (confirm: boolean) => void Vue.component('union-prop', { props: { @@ -79,16 +79,16 @@ Vue.component('union-prop', { union: [User, Number] as PropType }, data() { - this.cat; - this.complexUnion; - this.kittyUser; - this.callback(true); - this.union; + this.cat + this.complexUnion + this.kittyUser + this.callback(true) + this.union return { - fixedSize: this.union, + fixedSize: this.union } } -}); +}) Vue.component('union-prop-with-no-casting', { props: { @@ -98,10 +98,10 @@ Vue.component('union-prop-with-no-casting', { regex: RegExp }, data() { - this.mixed; - this.object; - this.primitive; - this.regex.compile; + this.mixed + this.object + this.primitive + this.regex.compile } }) @@ -113,9 +113,9 @@ Vue.component('prop-with-primitive-default', { } }, created(): void { - this.id; + this.id } -}); +}) Vue.component('component', { data() { @@ -130,40 +130,40 @@ Vue.component('component', { name: { type: String, default: '0', - required: true, + required: true } }, propsData: { - msg: "Hello" + msg: 'Hello' }, computed: { aDouble(): number { - return this.a * 2; + return this.a * 2 }, aPlus: { get(): number { - return this.a + 1; + return this.a + 1 }, set(v: number) { - this.a = v - 1; + this.a = v - 1 }, cache: false } }, methods: { plus(): void { - this.a++; - this.aDouble.toFixed(); - this.aPlus = 1; - this.size.toFixed(); + this.a++ + this.aDouble.toFixed() + this.aPlus = 1 + this.size.toFixed() } }, watch: { - 'a': function(val: number, oldVal: number) { - console.log(`new: ${val}, old: ${oldVal}`); + a: function (val: number, oldVal: number) { + console.log(`new: ${val}, old: ${oldVal}`) }, - 'b': 'someMethod', - 'c': { + b: 'someMethod', + c: { handler(val, oldVal) { this.a = val }, @@ -174,71 +174,77 @@ Vue.component('component', { immediate: true } }, - el: "#app", - template: "
{{ message }}
", + el: '#app', + template: '
{{ message }}
', render(createElement) { - return createElement("div", { - attrs: { - id: "foo" + return createElement( + 'div', + { + attrs: { + id: 'foo' + }, + props: { + myProp: 'bar' + }, + directives: [ + { + name: 'a', + value: 'foo' + } + ], + domProps: { + innerHTML: 'baz' + }, + on: { + click: new Function() + }, + nativeOn: { + click: new Function() + }, + class: { + foo: true, + bar: false + }, + style: { + color: 'red', + fontSize: '14px' + }, + key: 'myKey', + ref: 'myRef', + refInFor: true }, - props: { - myProp: "bar" - }, - directives: [{ - name: 'a', - value: 'foo' - }], - domProps: { - innerHTML: "baz" - }, - on: { - click: new Function - }, - nativeOn: { - click: new Function - }, - class: { - foo: true, - bar: false - }, - style: { - color: 'red', - fontSize: '14px' - }, - key: 'myKey', - ref: 'myRef', - refInFor: true - }, [ - createElement(), - createElement("div", "message"), - createElement(Vue.component("component")), - createElement({} as ComponentOptions), - createElement({ - functional: true, - render(c: CreateElement) { - return createElement() - } - }), + [ + createElement(), + createElement('div', 'message'), + createElement(Vue.component('component')), + createElement({} as ComponentOptions), + createElement({ + functional: true, + render(c: CreateElement) { + return createElement() + } + }), - createElement(() => Vue.component("component")), - createElement(() => ( {} as ComponentOptions )), - createElement((resolve, reject) => { - resolve({} as ComponentOptions); - reject(); - }), + createElement(() => Vue.component('component')), + createElement(() => ({} as ComponentOptions)), + createElement((resolve, reject) => { + resolve({} as ComponentOptions) + reject() + }), - "message", + 'message', - [createElement("div", "message")] - ]); + [createElement('div', 'message')] + ] + ) }, renderError(createElement, err) { - return createElement('pre', { style: { color: 'red' }}, err.stack) + return createElement('pre', { style: { color: 'red' } }, err.stack) }, staticRenderFns: [], beforeCreate() { - (this as any).a = 1; + ;(this as any).a = 1 }, created() {}, beforeDestroy() {}, @@ -255,7 +261,7 @@ Vue.component('component', { info.toUpperCase() return true }, - serverPrefetch () { + serverPrefetch() { return Promise.resolve() }, @@ -268,44 +274,43 @@ Vue.component('component', { unbind() {} }, b(el, binding, vnode, oldVnode) { - el.textContent; + el.textContent - binding.name; - binding.value; - binding.oldValue; - binding.expression; - binding.arg; - binding.modifiers["modifier"]; + binding.name + binding.value + binding.oldValue + binding.expression + binding.arg + binding.modifiers['modifier'] } }, components: { - a: Vue.component(""), + a: Vue.component(''), b: {} as ComponentOptions }, transitions: {}, filters: { double(value: number) { - return value * 2; + return value * 2 } }, - parent: new Vue, - mixins: [Vue.component(""), ({} as ComponentOptions)], - name: "Component", + parent: new Vue(), + mixins: [Vue.component(''), {} as ComponentOptions], + name: 'Component', extends: {} as ComponentOptions, - delimiters: ["${", "}"] -}); - + delimiters: ['${', '}'] +}) Vue.component('custom-prop-type-function', { props: { - callback: Function as PropType<(confirm: boolean) => void>, + callback: Function as PropType<(confirm: boolean) => void> }, methods: { - confirm(){ - this.callback(true); + confirm() { + this.callback(true) } } -}); +}) Vue.component('provide-inject', { provide: { @@ -316,7 +321,7 @@ Vue.component('provide-inject', { injectBar: Symbol(), injectBaz: { from: 'baz' }, injectQux: { default: 1 }, - injectQuux: { from: 'quuz', default: () => ({ value: 1 })} + injectQuux: { from: 'quuz', default: () => ({ value: 1 }) } } }) @@ -327,13 +332,13 @@ Vue.component('provide-function', { }) Vue.component('component-with-slot', { - render (h): VNode { + render(h): VNode { return h('div', this.$slots.default) } }) Vue.component('component-with-scoped-slot', { - render (h) { + render(h) { interface ScopedSlotProps { msg: string } @@ -367,11 +372,12 @@ Vue.component('component-with-scoped-slot', { }, components: { child: { - render (this: Vue, h: CreateElement) { + render(this: Vue, h: CreateElement) { const defaultSlot = this.$scopedSlots['default']!({ msg: 'hi' }) - defaultSlot && defaultSlot.forEach(vnode => { - vnode.tag - }) + defaultSlot && + defaultSlot.forEach(vnode => { + vnode.tag + }) return h('div', [ defaultSlot, this.$scopedSlots['item']!({ msg: 'hello' }) @@ -382,7 +388,7 @@ Vue.component('component-with-scoped-slot', { }) Vue.component('narrow-array-of-vnode-type', { - render (h): VNode { + render(h): VNode { const slot = this.$scopedSlots.default!({}) if (typeof slot === 'string') { // @@ -410,16 +416,16 @@ Vue.component('functional-component', { functional: true, inject: ['foo'], render(createElement, context) { - context.props; - context.children; - context.slots(); - context.data; - context.parent; - context.scopedSlots; - context.listeners.click; - return createElement("div", {}, context.children); + context.props + context.children + context.slots() + context.data + context.parent + context.scopedSlots + context.listeners.click + return createElement('div', {}, context.children) } -}); +}) Vue.component('functional-component-object-inject', { functional: true, @@ -428,7 +434,7 @@ Vue.component('functional-component-object-inject', { bar: Symbol(), baz: { from: 'baz' }, qux: { default: 1 }, - quux: { from: 'quuz', default: () => ({ value: 1 })} + quux: { from: 'quuz', default: () => ({ value: 1 }) } }, render(h) { return h('div') @@ -443,23 +449,25 @@ Vue.component('functional-component-multi-root', { functional: true, render(h) { return [ - h("tr", [h("td", "foo"), h("td", "bar")]), - h("tr", [h("td", "lorem"), h("td", "ipsum")]) + h('tr', [h('td', 'foo'), h('td', 'bar')]), + h('tr', [h('td', 'lorem'), h('td', 'ipsum')]) ] } }) -Vue.component("async-component", ((resolve, reject) => { +Vue.component('async-component', (resolve, reject) => { setTimeout(() => { - resolve(Vue.component("component")); - }, 0); - return new Promise((resolve) => { + resolve(Vue.component('component')) + }, 0) + return new Promise(resolve => { resolve({ functional: true, - render(h: CreateElement) { return h('div') } - }); + render(h: CreateElement) { + return h('div') + } + }) }) -})); +}) Vue.component('functional-component-v-model', { props: ['foo'], @@ -469,33 +477,33 @@ Vue.component('functional-component-v-model', { event: 'change' }, render(createElement, context) { - return createElement("input", { + return createElement('input', { on: { input: new Function() }, domProps: { value: context.props.foo } - }); + }) } -}); - +}) Vue.component('async-es-module-component', () => import('./es-module')) Vue.component('directive-expression-optional-string', { render(createElement) { - return createElement("div", { + return createElement('div', { directives: [ { name: 'has-expression', value: 2, - expression: '1 + 1', - }, { - name: 'no-expression', - value: 'foo', + expression: '1 + 1' }, - ], + { + name: 'no-expression', + value: 'foo' + } + ] }) } -}); +}) diff --git a/types/test/plugin-test.ts b/types/test/plugin-test.ts index ebb352e82..c6c480343 100644 --- a/types/test/plugin-test.ts +++ b/types/test/plugin-test.ts @@ -1,20 +1,20 @@ -import Vue from "../index"; -import { PluginFunction, PluginObject } from "../index"; +import Vue from '../index' +import { PluginFunction, PluginObject } from '../index' class Option { - prefix: string = ""; - suffix: string = ""; + prefix: string = '' + suffix: string = '' } const plugin: PluginObject