types: massive refactor

This commit is contained in:
Evan You
2019-10-22 11:26:48 -04:00
parent 522beaa766
commit b5886189ba
21 changed files with 308 additions and 258 deletions

View File

@@ -2,8 +2,12 @@ import { VNodeChild } from '../vnode'
import { isArray, isString, isObject } from '@vue/shared'
export function renderList(
source: any,
renderItem: (value: any, key: string | number, index?: number) => VNodeChild
source: unknown,
renderItem: (
value: unknown,
key: string | number,
index?: number
) => VNodeChild
): VNodeChild[] {
let ret: VNodeChild[]
if (isArray(source) || isString(source)) {

View File

@@ -1,3 +1,4 @@
import { Data } from '../component'
import { Slot } from '../componentSlots'
import {
VNodeChildren,
@@ -11,7 +12,7 @@ import { PatchFlags } from '@vue/shared'
export function renderSlot(
slots: Record<string, Slot>,
name: string,
props: any = {},
props: Data = {},
// this is not a user-facing function, so the fallback is always generated by
// the compiler and guaranteed to be an array
fallback?: VNodeChildren

View File

@@ -1,10 +1,10 @@
import { isArray, isPlainObject, objectToString } from '@vue/shared'
// for converting {{ interpolation }} values to displayed strings.
export function toString(val: any): string {
export function toString(val: unknown): string {
return val == null
? ''
: isArray(val) || (isPlainObject(val) && val.toString === objectToString)
? JSON.stringify(val, null, 2)
: String(val)
? JSON.stringify(val, null, 2)
: String(val)
}