diff --git a/types/index.d.ts b/types/index.d.ts index 144dfff5322..dae1d3ad044 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -11,8 +11,8 @@ declare namespace Vue { export type Component = Options.Component; export type AsyncComponent = Options.AsyncComponent; export type ComponentOptions = Options.ComponentOptions; - export type FunctionalComponentOptions = Options.FunctionalComponentOptions; - export type RenderContext = Options.RenderContext; + export type FunctionalComponentOptions = Options.FunctionalComponentOptions; + export type RenderContext = Options.RenderContext; export type PropOptions = Options.PropOptions; export type ComputedOptions = Options.ComputedOptions; export type WatchHandler = Options.WatchHandler; diff --git a/types/options.d.ts b/types/options.d.ts index 1ab02f85952..a728237a5d9 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -5,7 +5,7 @@ type Constructor = { new (...args: any[]): any; } -export type Component = typeof Vue | ComponentOptions | FunctionalComponentOptions; +export type Component = typeof Vue | ComponentOptions | FunctionalComponentOptions; export type AsyncComponent = ( resolve: (component: Component) => void, reject: (reason?: any) => void @@ -45,17 +45,17 @@ export interface ComponentOptions { delimiters?: [string, string]; } -export interface FunctionalComponentOptions { +export interface FunctionalComponentOptions { props?: string[] | { [key: string]: PropOptions | Constructor | Constructor[] }; functional: boolean; - render(this: never, createElement: CreateElement, context: RenderContext): VNode; + render(this: never, createElement: CreateElement, context: RenderContext): VNode; name?: string; } -export interface RenderContext { - props: any; +export interface RenderContext { + props: P; children: VNode[]; - slots: any; + slots(): S; data: VNodeData; parent: Vue; } diff --git a/types/test/options-test.ts b/types/test/options-test.ts index b5cdd194384..15b55ff1a90 100644 --- a/types/test/options-test.ts +++ b/types/test/options-test.ts @@ -171,13 +171,13 @@ Vue.component('functional-component', { context.parent; return createElement("div", {}, context.children); } -} as FunctionalComponentOptions); +} as FunctionalComponentOptions<{}, {}>); Vue.component("async-component", (resolve, reject) => { setTimeout(() => { resolve(Vue.component("component")); }, 0); return new Promise((resolve) => { - resolve({ functional: true } as FunctionalComponentOptions); + resolve({ functional: true } as FunctionalComponentOptions<{}, {}>); }) }); diff --git a/types/vue.d.ts b/types/vue.d.ts index 4935a996423..915a5c1c4ac 100644 --- a/types/vue.d.ts +++ b/types/vue.d.ts @@ -67,7 +67,7 @@ export declare class Vue { keyCodes: { [key: string]: number }; } - static extend(options: ComponentOptions | FunctionalComponentOptions): typeof Vue; + static extend(options: ComponentOptions | FunctionalComponentOptions): typeof Vue; static nextTick(callback: () => void, context?: any[]): void; static set(object: Object, key: string, value: T): T; static set(array: T[], key: number, value: T): T;