diff --git a/packages/runtime-core/src/helpers/renderList.ts b/packages/runtime-core/src/helpers/renderList.ts index f45020d4..5dd68d6b 100644 --- a/packages/runtime-core/src/helpers/renderList.ts +++ b/packages/runtime-core/src/helpers/renderList.ts @@ -1,13 +1,44 @@ import { VNodeChild } from '../vnode' import { isArray, isString, isObject } from '@vue/shared' +// v-for string export function renderList( - source: unknown, - renderItem: ( - value: unknown, - key: string | number, - index?: number + source: string, + renderItem: (value: string, index: number) => VNodeChild +): VNodeChild[] + +// v-for number +export function renderList( + source: number, + renderItem: (value: number, index: number) => VNodeChild +): VNodeChild[] + +// v-for array +export function renderList( + source: T[], + renderItem: (value: T, index: number) => VNodeChild +): VNodeChild[] + +// v-for iterable +export function renderList( + source: Iterable, + renderItem: (value: T, index: number) => VNodeChild +): VNodeChild[] + +// v-for object +export function renderList( + source: T, + renderItem: ( + value: T[K], + key: K, + index: number ) => VNodeChild +): VNodeChild[] + +// actual implementation +export function renderList( + source: any, + renderItem: (...args: any[]) => VNodeChild ): VNodeChild[] { let ret: VNodeChild[] if (isArray(source) || isString(source)) {