mirror of
https://gitee.com/vuejs/vue.git
synced 2024-11-30 02:57:43 +08:00
fix(types): make VNodeChildrenArrayContents type more accurate (#7287)
This commit is contained in:
parent
e055df82fe
commit
49aae6bb15
@ -1,4 +1,4 @@
|
||||
import Vue from "../index";
|
||||
import Vue, { VNode } from "../index";
|
||||
import { AsyncComponent, ComponentOptions, FunctionalComponentOptions } from "../index";
|
||||
import { CreateElement } from "../vue";
|
||||
|
||||
@ -277,6 +277,19 @@ Vue.component('component-with-scoped-slot', {
|
||||
}
|
||||
})
|
||||
|
||||
Vue.component('narrow-array-of-vnode-type', {
|
||||
render (h): VNode {
|
||||
const slot = this.$scopedSlots.default({})
|
||||
if (typeof slot !== 'string') {
|
||||
const first = slot[0]
|
||||
if (!Array.isArray(first) && typeof first !== 'string') {
|
||||
return first;
|
||||
}
|
||||
}
|
||||
return h();
|
||||
}
|
||||
})
|
||||
|
||||
Vue.component('functional-component', {
|
||||
props: ['prop'],
|
||||
functional: true,
|
||||
|
4
types/vnode.d.ts
vendored
4
types/vnode.d.ts
vendored
@ -3,9 +3,7 @@ import { Vue } from "./vue";
|
||||
export type ScopedSlot = (props: any) => VNodeChildrenArrayContents | string;
|
||||
|
||||
export type VNodeChildren = VNodeChildrenArrayContents | [ScopedSlot] | string;
|
||||
export interface VNodeChildrenArrayContents {
|
||||
[x: number]: VNode | string | VNodeChildren;
|
||||
}
|
||||
export interface VNodeChildrenArrayContents extends Array<VNode | string | VNodeChildrenArrayContents> {}
|
||||
|
||||
export interface VNode {
|
||||
tag?: string;
|
||||
|
Loading…
Reference in New Issue
Block a user