[improvement] optimize sfc type definitions (#2778)

This commit is contained in:
neverland
2019-02-18 17:34:32 +08:00
committed by GitHub
parent 0013185d38
commit 78174e4550
8 changed files with 131 additions and 97 deletions

View File

@@ -13,13 +13,16 @@ import Vue, {
import { VNode } from 'vue/types/vnode';
import { InjectOptions, PropsDefinition } from 'vue/types/options';
export type ScopedSlot = (props?: any) => VNode[] | undefined;
export type ScopedSlot<Props = any> = (props?: Props) => VNode[] | undefined;
export type ScopedSlots = {
[key: string]: ScopedSlot | undefined;
export type DefaultSlots = {
default?: ScopedSlot;
};
export type ScopedSlots = DefaultSlots & {
[key: string]: ScopedSlot | undefined;
};
export type ModelOptions = {
prop?: string;
event?: string;
@@ -50,7 +53,7 @@ export type FunctionalComponent<
export type TsxBaseProps = {
class?: any;
style?: any;
}
};
export type TsxComponent<T> = (props: T & TsxBaseProps) => VNode;
const arrayProp = {
@@ -102,7 +105,8 @@ function transformFunctionalComponent(
functional: true,
props: pure.props,
model: pure.model,
render: (h, context): any => pure(h, context.props, unifySlots(context), context)
render: (h, context): any =>
pure(h, context.props, unifySlots(context), context)
};
}