Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ declare namespace Vue {
export type Component = Options.Component;
export type AsyncComponent = Options.AsyncComponent;
export type ComponentOptions<V extends Vue> = Options.ComponentOptions<V>;
export type FunctionalComponentOptions = Options.FunctionalComponentOptions;
export type RenderContext = Options.RenderContext;
export type FunctionalComponentOptions<P, S> = Options.FunctionalComponentOptions<P, S>;
export type RenderContext<P, S> = Options.RenderContext<P, S>;
export type PropOptions = Options.PropOptions;
export type ComputedOptions<V extends Vue> = Options.ComputedOptions<V>;
export type WatchHandler<V extends Vue> = Options.WatchHandler<V>;
Expand Down
12 changes: 6 additions & 6 deletions types/options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type Constructor = {
new (...args: any[]): any;
}

export type Component = typeof Vue | ComponentOptions<Vue> | FunctionalComponentOptions;
export type Component = typeof Vue | ComponentOptions<Vue> | FunctionalComponentOptions<any, any>;
export type AsyncComponent = (
resolve: (component: Component) => void,
reject: (reason?: any) => void
Expand Down Expand Up @@ -45,17 +45,17 @@ export interface ComponentOptions<V extends Vue> {
delimiters?: [string, string];
}

export interface FunctionalComponentOptions {
export interface FunctionalComponentOptions<P, S> {
props?: string[] | { [key: string]: PropOptions | Constructor | Constructor[] };
functional: boolean;
render(this: never, createElement: CreateElement, context: RenderContext): VNode;
render(this: never, createElement: CreateElement, context: RenderContext<P, S>): VNode;
name?: string;
}

export interface RenderContext {
props: any;
export interface RenderContext<P, S> {
props: P;
children: VNode[];
slots: any;
slots(): S;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this changed to method? In my understand, it should a property of an object.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to a document, it is a function that returns a dictionary.
http://vuejs.org/guide/render-function.html#Functional-Components

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, indeed! I was confused with this.$slots 😆

data: VNodeData;
parent: Vue;
}
Expand Down
4 changes: 2 additions & 2 deletions types/test/options-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<{}, {}>);
})
});
2 changes: 1 addition & 1 deletion types/vue.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export declare class Vue {
keyCodes: { [key: string]: number };
}

static extend(options: ComponentOptions<Vue> | FunctionalComponentOptions): typeof Vue;
static extend(options: ComponentOptions<Vue> | FunctionalComponentOptions<any, any>): typeof Vue;
static nextTick(callback: () => void, context?: any[]): void;
static set<T>(object: Object, key: string, value: T): T;
static set<T>(array: T[], key: number, value: T): T;
Expand Down