types(runtime-core): Adds type signature for renderList helper (#924)
This commit is contained in:
parent
da1fb7afef
commit
4d196366c8
@ -1,13 +1,44 @@
|
|||||||
import { VNodeChild } from '../vnode'
|
import { VNodeChild } from '../vnode'
|
||||||
import { isArray, isString, isObject } from '@vue/shared'
|
import { isArray, isString, isObject } from '@vue/shared'
|
||||||
|
|
||||||
|
// v-for string
|
||||||
export function renderList(
|
export function renderList(
|
||||||
source: unknown,
|
source: string,
|
||||||
renderItem: (
|
renderItem: (value: string, index: number) => VNodeChild
|
||||||
value: unknown,
|
): VNodeChild[]
|
||||||
key: string | number,
|
|
||||||
index?: number
|
// v-for number
|
||||||
|
export function renderList(
|
||||||
|
source: number,
|
||||||
|
renderItem: (value: number, index: number) => VNodeChild
|
||||||
|
): VNodeChild[]
|
||||||
|
|
||||||
|
// v-for array
|
||||||
|
export function renderList<T>(
|
||||||
|
source: T[],
|
||||||
|
renderItem: (value: T, index: number) => VNodeChild
|
||||||
|
): VNodeChild[]
|
||||||
|
|
||||||
|
// v-for iterable
|
||||||
|
export function renderList<T>(
|
||||||
|
source: Iterable<T>,
|
||||||
|
renderItem: (value: T, index: number) => VNodeChild
|
||||||
|
): VNodeChild[]
|
||||||
|
|
||||||
|
// v-for object
|
||||||
|
export function renderList<T>(
|
||||||
|
source: T,
|
||||||
|
renderItem: <K extends keyof T>(
|
||||||
|
value: T[K],
|
||||||
|
key: K,
|
||||||
|
index: number
|
||||||
) => VNodeChild
|
) => VNodeChild
|
||||||
|
): VNodeChild[]
|
||||||
|
|
||||||
|
// actual implementation
|
||||||
|
export function renderList(
|
||||||
|
source: any,
|
||||||
|
renderItem: (...args: any[]) => VNodeChild
|
||||||
): VNodeChild[] {
|
): VNodeChild[] {
|
||||||
let ret: VNodeChild[]
|
let ret: VNodeChild[]
|
||||||
if (isArray(source) || isString(source)) {
|
if (isArray(source) || isString(source)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user