chore: replace some type casts and fix variable and filename typos (#93)
This commit is contained in:
committed by
Evan You
parent
23ff681418
commit
fbabae0c0a
@@ -110,7 +110,7 @@ export interface MethodOptions {
|
||||
[key: string]: Function
|
||||
}
|
||||
|
||||
export type ExtracComputedReturns<T extends any> = {
|
||||
export type ExtractComputedReturns<T extends any> = {
|
||||
[key in keyof T]: T[key] extends { get: Function }
|
||||
? ReturnType<T[key]['get']>
|
||||
: ReturnType<T[key]>
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ComponentInternalInstance, Data } from './component'
|
||||
import { nextTick } from './scheduler'
|
||||
import { instanceWatch } from './apiWatch'
|
||||
import { EMPTY_OBJ, hasOwn, globalsWhitelist } from '@vue/shared'
|
||||
import { ExtracComputedReturns } from './apiOptions'
|
||||
import { ExtractComputedReturns } from './apiOptions'
|
||||
import { UnwrapRef } from '@vue/reactivity'
|
||||
|
||||
// public properties exposed on the proxy, which is used as the render context
|
||||
@@ -26,7 +26,7 @@ export type ComponentPublicInstance<
|
||||
} & P &
|
||||
UnwrapRef<B> &
|
||||
D &
|
||||
ExtracComputedReturns<C> &
|
||||
ExtractComputedReturns<C> &
|
||||
M
|
||||
|
||||
export const PublicInstanceProxyHandlers = {
|
||||
|
||||
@@ -149,7 +149,7 @@ export function createRenderer<
|
||||
} {
|
||||
type HostVNode = VNode<HostNode, HostElement>
|
||||
type HostVNodeChildren = VNodeChildren<HostNode, HostElement>
|
||||
type HostSuspsenseBoundary = SuspenseBoundary<HostNode, HostElement>
|
||||
type HostSuspenseBoundary = SuspenseBoundary<HostNode, HostElement>
|
||||
|
||||
const {
|
||||
insert: hostInsert,
|
||||
@@ -171,7 +171,7 @@ export function createRenderer<
|
||||
container: HostElement,
|
||||
anchor: HostNode | null = null,
|
||||
parentComponent: ComponentInternalInstance | null = null,
|
||||
parentSuspense: HostSuspsenseBoundary | null = null,
|
||||
parentSuspense: HostSuspenseBoundary | null = null,
|
||||
isSVG: boolean = false,
|
||||
optimized: boolean = false
|
||||
) {
|
||||
@@ -303,7 +303,7 @@ export function createRenderer<
|
||||
container: HostElement,
|
||||
anchor: HostNode | null,
|
||||
parentComponent: ComponentInternalInstance | null,
|
||||
parentSuspense: HostSuspsenseBoundary | null,
|
||||
parentSuspense: HostSuspenseBoundary | null,
|
||||
isSVG: boolean,
|
||||
optimized: boolean
|
||||
) {
|
||||
@@ -329,7 +329,7 @@ export function createRenderer<
|
||||
container: HostElement,
|
||||
anchor: HostNode | null,
|
||||
parentComponent: ComponentInternalInstance | null,
|
||||
parentSuspense: HostSuspsenseBoundary | null,
|
||||
parentSuspense: HostSuspenseBoundary | null,
|
||||
isSVG: boolean
|
||||
) {
|
||||
const tag = vnode.type as string
|
||||
@@ -370,7 +370,7 @@ export function createRenderer<
|
||||
container: HostElement,
|
||||
anchor: HostNode | null,
|
||||
parentComponent: ComponentInternalInstance | null,
|
||||
parentSuspense: HostSuspsenseBoundary | null,
|
||||
parentSuspense: HostSuspenseBoundary | null,
|
||||
isSVG: boolean,
|
||||
start: number = 0
|
||||
) {
|
||||
@@ -392,7 +392,7 @@ export function createRenderer<
|
||||
n1: HostVNode,
|
||||
n2: HostVNode,
|
||||
parentComponent: ComponentInternalInstance | null,
|
||||
parentSuspense: HostSuspsenseBoundary | null,
|
||||
parentSuspense: HostSuspenseBoundary | null,
|
||||
isSVG: boolean,
|
||||
optimized: boolean
|
||||
) {
|
||||
@@ -491,10 +491,10 @@ export function createRenderer<
|
||||
|
||||
if (dynamicChildren != null) {
|
||||
// children fast path
|
||||
const olddynamicChildren = n1.dynamicChildren!
|
||||
const oldDynamicChildren = n1.dynamicChildren!
|
||||
for (let i = 0; i < dynamicChildren.length; i++) {
|
||||
patch(
|
||||
olddynamicChildren[i],
|
||||
oldDynamicChildren[i],
|
||||
dynamicChildren[i],
|
||||
el,
|
||||
null,
|
||||
@@ -522,7 +522,7 @@ export function createRenderer<
|
||||
oldProps: any,
|
||||
newProps: any,
|
||||
parentComponent: ComponentInternalInstance | null,
|
||||
parentSuspense: HostSuspsenseBoundary | null,
|
||||
parentSuspense: HostSuspenseBoundary | null,
|
||||
isSVG: boolean
|
||||
) {
|
||||
if (oldProps !== newProps) {
|
||||
@@ -571,7 +571,7 @@ export function createRenderer<
|
||||
container: HostElement,
|
||||
anchor: HostNode | null,
|
||||
parentComponent: ComponentInternalInstance | null,
|
||||
parentSuspense: HostSuspsenseBoundary | null,
|
||||
parentSuspense: HostSuspenseBoundary | null,
|
||||
isSVG: boolean,
|
||||
optimized: boolean
|
||||
) {
|
||||
@@ -613,7 +613,7 @@ export function createRenderer<
|
||||
container: HostElement,
|
||||
anchor: HostNode | null,
|
||||
parentComponent: ComponentInternalInstance | null,
|
||||
parentSuspense: HostSuspsenseBoundary | null,
|
||||
parentSuspense: HostSuspenseBoundary | null,
|
||||
isSVG: boolean,
|
||||
optimized: boolean
|
||||
) {
|
||||
@@ -685,7 +685,7 @@ export function createRenderer<
|
||||
container: HostElement,
|
||||
anchor: HostNode | null,
|
||||
parentComponent: ComponentInternalInstance | null,
|
||||
parentSuspense: HostSuspsenseBoundary | null,
|
||||
parentSuspense: HostSuspenseBoundary | null,
|
||||
isSVG: boolean,
|
||||
optimized: boolean
|
||||
) {
|
||||
@@ -717,7 +717,7 @@ export function createRenderer<
|
||||
container: HostElement,
|
||||
anchor: HostNode | null,
|
||||
parentComponent: ComponentInternalInstance | null,
|
||||
parentSuspense: HostSuspsenseBoundary | null,
|
||||
parentSuspense: HostSuspenseBoundary | null,
|
||||
isSVG: boolean,
|
||||
optimized: boolean
|
||||
) {
|
||||
@@ -828,7 +828,7 @@ export function createRenderer<
|
||||
suspense.fallbackTree = fallback
|
||||
}
|
||||
|
||||
function resolveSuspense(suspense: HostSuspsenseBoundary) {
|
||||
function resolveSuspense(suspense: HostSuspenseBoundary) {
|
||||
if (__DEV__) {
|
||||
if (suspense.isResolved) {
|
||||
throw new Error(
|
||||
@@ -861,7 +861,7 @@ export function createRenderer<
|
||||
}
|
||||
// move content from off-dom container to actual container
|
||||
move(subTree as HostVNode, container, anchor)
|
||||
const el = (vnode.el = (subTree as HostVNode).el as HostNode)
|
||||
const el = (vnode.el = (subTree as HostVNode).el!)
|
||||
// suspense as the root node of a component...
|
||||
if (parentComponent && parentComponent.subTree === vnode) {
|
||||
parentComponent.vnode.el = el
|
||||
@@ -892,7 +892,7 @@ export function createRenderer<
|
||||
}
|
||||
}
|
||||
|
||||
function restartSuspense(suspense: HostSuspsenseBoundary) {
|
||||
function restartSuspense(suspense: HostSuspenseBoundary) {
|
||||
suspense.isResolved = false
|
||||
const {
|
||||
vnode,
|
||||
@@ -919,7 +919,7 @@ export function createRenderer<
|
||||
isSVG,
|
||||
optimized
|
||||
)
|
||||
const el = (vnode.el = (fallbackTree as HostVNode).el as HostNode)
|
||||
const el = (vnode.el = (fallbackTree as HostVNode).el!)
|
||||
// suspense as the root node of a component...
|
||||
if (parentComponent && parentComponent.subTree === vnode) {
|
||||
parentComponent.vnode.el = el
|
||||
@@ -939,7 +939,7 @@ export function createRenderer<
|
||||
container: HostElement,
|
||||
anchor: HostNode | null,
|
||||
parentComponent: ComponentInternalInstance | null,
|
||||
parentSuspense: HostSuspsenseBoundary | null,
|
||||
parentSuspense: HostSuspenseBoundary | null,
|
||||
isSVG: boolean,
|
||||
optimized: boolean
|
||||
) {
|
||||
@@ -993,7 +993,7 @@ export function createRenderer<
|
||||
container: HostElement,
|
||||
anchor: HostNode | null,
|
||||
parentComponent: ComponentInternalInstance | null,
|
||||
parentSuspense: HostSuspsenseBoundary | null,
|
||||
parentSuspense: HostSuspenseBoundary | null,
|
||||
isSVG: boolean
|
||||
) {
|
||||
const instance: ComponentInternalInstance = (initialVNode.component = createComponentInstance(
|
||||
@@ -1073,7 +1073,7 @@ export function createRenderer<
|
||||
function retryAsyncComponent(
|
||||
instance: ComponentInternalInstance,
|
||||
asyncSetupResult: unknown,
|
||||
parentSuspense: HostSuspsenseBoundary,
|
||||
parentSuspense: HostSuspenseBoundary,
|
||||
isSVG: boolean
|
||||
) {
|
||||
parentSuspense.deps--
|
||||
@@ -1104,7 +1104,7 @@ export function createRenderer<
|
||||
|
||||
function setupRenderEffect(
|
||||
instance: ComponentInternalInstance,
|
||||
parentSuspense: HostSuspsenseBoundary | null,
|
||||
parentSuspense: HostSuspenseBoundary | null,
|
||||
initialVNode: HostVNode,
|
||||
container: HostElement,
|
||||
anchor: HostNode | null,
|
||||
@@ -1168,7 +1168,7 @@ export function createRenderer<
|
||||
// to child component's vnode
|
||||
updateHOCHostEl(instance, nextTree.el)
|
||||
}
|
||||
// upated hook
|
||||
// updated hook
|
||||
if (instance.u !== null) {
|
||||
queuePostRenderEffect(instance.u, parentSuspense)
|
||||
}
|
||||
@@ -1207,7 +1207,7 @@ export function createRenderer<
|
||||
container: HostElement,
|
||||
anchor: HostNode | null,
|
||||
parentComponent: ComponentInternalInstance | null,
|
||||
parentSuspense: HostSuspsenseBoundary | null,
|
||||
parentSuspense: HostSuspenseBoundary | null,
|
||||
isSVG: boolean,
|
||||
optimized: boolean = false
|
||||
) {
|
||||
@@ -1311,7 +1311,7 @@ export function createRenderer<
|
||||
container: HostElement,
|
||||
anchor: HostNode | null,
|
||||
parentComponent: ComponentInternalInstance | null,
|
||||
parentSuspense: HostSuspsenseBoundary | null,
|
||||
parentSuspense: HostSuspenseBoundary | null,
|
||||
isSVG: boolean,
|
||||
optimized: boolean
|
||||
) {
|
||||
@@ -1358,7 +1358,7 @@ export function createRenderer<
|
||||
container: HostElement,
|
||||
parentAnchor: HostNode | null,
|
||||
parentComponent: ComponentInternalInstance | null,
|
||||
parentSuspense: HostSuspsenseBoundary | null,
|
||||
parentSuspense: HostSuspenseBoundary | null,
|
||||
isSVG: boolean,
|
||||
optimized: boolean
|
||||
) {
|
||||
@@ -1464,7 +1464,7 @@ export function createRenderer<
|
||||
const s2 = i // next starting index
|
||||
|
||||
// 5.1 build key:index map for newChildren
|
||||
const keyToNewIndexMap: Map<any, number> = new Map()
|
||||
const keyToNewIndexMap: Map<string | number, number> = new Map()
|
||||
for (i = s2; i <= e2; i++) {
|
||||
const nextChild = (c2[i] = normalizeVNode(c2[i]))
|
||||
if (nextChild.key != null) {
|
||||
@@ -1613,7 +1613,7 @@ export function createRenderer<
|
||||
function unmount(
|
||||
vnode: HostVNode,
|
||||
parentComponent: ComponentInternalInstance | null,
|
||||
parentSuspense: HostSuspsenseBoundary | null,
|
||||
parentSuspense: HostSuspenseBoundary | null,
|
||||
doRemove?: boolean
|
||||
) {
|
||||
const {
|
||||
@@ -1678,7 +1678,7 @@ export function createRenderer<
|
||||
|
||||
function unmountComponent(
|
||||
instance: ComponentInternalInstance,
|
||||
parentSuspense: HostSuspsenseBoundary | null,
|
||||
parentSuspense: HostSuspenseBoundary | null,
|
||||
doRemove?: boolean
|
||||
) {
|
||||
const { bum, effects, update, subTree, um } = instance
|
||||
@@ -1724,9 +1724,9 @@ export function createRenderer<
|
||||
}
|
||||
|
||||
function unmountSuspense(
|
||||
suspense: HostSuspsenseBoundary,
|
||||
suspense: HostSuspenseBoundary,
|
||||
parentComponent: ComponentInternalInstance | null,
|
||||
parentSuspense: HostSuspsenseBoundary | null,
|
||||
parentSuspense: HostSuspenseBoundary | null,
|
||||
doRemove?: boolean
|
||||
) {
|
||||
suspense.isUnmounted = true
|
||||
@@ -1739,7 +1739,7 @@ export function createRenderer<
|
||||
function unmountChildren(
|
||||
children: HostVNode[],
|
||||
parentComponent: ComponentInternalInstance | null,
|
||||
parentSuspense: HostSuspsenseBoundary | null,
|
||||
parentSuspense: HostSuspenseBoundary | null,
|
||||
doRemove?: boolean,
|
||||
start: number = 0
|
||||
) {
|
||||
|
||||
@@ -86,7 +86,7 @@ export function handleError(
|
||||
) {
|
||||
const contextVNode = instance ? instance.vnode : null
|
||||
if (instance) {
|
||||
let cur: ComponentInternalInstance | null = instance.parent
|
||||
let cur = instance.parent
|
||||
// the exposed instance is the render proxy to keep it consistent with 2.x
|
||||
const exposedInstance = instance.renderProxy
|
||||
// in production the hook receives only the error code
|
||||
|
||||
@@ -97,8 +97,8 @@ const blockStack: (VNode[] | null)[] = []
|
||||
//
|
||||
// disableTracking is true when creating a fragment block, since a fragment
|
||||
// always diffs its children.
|
||||
export function openBlock(disableTrackng?: boolean) {
|
||||
blockStack.push(disableTrackng ? null : [])
|
||||
export function openBlock(disableTracking?: boolean) {
|
||||
blockStack.push(disableTracking ? null : [])
|
||||
}
|
||||
|
||||
let shouldTrack = true
|
||||
|
||||
@@ -65,14 +65,14 @@ function getComponentTrace(): ComponentTraceStack {
|
||||
// we can't just use the stack because it will be incomplete during updates
|
||||
// that did not start from the root. Re-construct the parent chain using
|
||||
// instance parent pointers.
|
||||
const normlaizedStack: ComponentTraceStack = []
|
||||
const normalizeStack: ComponentTraceStack = []
|
||||
|
||||
while (currentVNode) {
|
||||
const last = normlaizedStack[0]
|
||||
const last = normalizeStack[0]
|
||||
if (last && last.vnode === currentVNode) {
|
||||
last.recurseCount++
|
||||
} else {
|
||||
normlaizedStack.push({
|
||||
normalizeStack.push({
|
||||
vnode: currentVNode,
|
||||
recurseCount: 0
|
||||
})
|
||||
@@ -82,7 +82,7 @@ function getComponentTrace(): ComponentTraceStack {
|
||||
currentVNode = parentInstance && parentInstance.vnode
|
||||
}
|
||||
|
||||
return normlaizedStack
|
||||
return normalizeStack
|
||||
}
|
||||
|
||||
function formatTrace(trace: ComponentTraceStack): string[] {
|
||||
|
||||
Reference in New Issue
Block a user