chore: replace some type casts and fix variable and filename typos (#93)

This commit is contained in:
Carlos Rodrigues 2019-10-05 15:38:02 +01:00 committed by Evan You
parent 23ff681418
commit fbabae0c0a
10 changed files with 51 additions and 51 deletions

View File

@ -39,7 +39,7 @@ export type DirectiveTransform = (
needRuntime: boolean
}
// A structural directive transform is a techically a NodeTransform;
// A structural directive transform is a technically a NodeTransform;
// Only v-if and v-for fall into this category.
export type StructuralDirectiveTransform = (
node: ElementNode,
@ -191,11 +191,11 @@ function createTransformContext(
if (identifiers[id] === undefined) {
identifiers[id] = 0
}
;(identifiers[id] as number)++
identifiers[id]!++
}
function removeId(id: string) {
;(context.identifiers[id] as number)--
context.identifiers[id]!--
}
return context

View File

@ -191,7 +191,7 @@ export function buildProps(
let hasDynamicKeys = false
const dynamicPropNames: string[] = []
const anaylizePatchFlag = ({ key, value }: Property) => {
const analyzePatchFlag = ({ key, value }: Property) => {
if (key.type === NodeTypes.SIMPLE_EXPRESSION && key.isStatic) {
if (value.type !== NodeTypes.SIMPLE_EXPRESSION || !value.isStatic) {
const name = key.content
@ -288,10 +288,10 @@ export function buildProps(
const { props, needRuntime } = directiveTransform(prop, context)
if (isArray(props)) {
properties.push(...props)
properties.forEach(anaylizePatchFlag)
properties.forEach(analyzePatchFlag)
} else {
properties.push(props)
anaylizePatchFlag(props)
analyzePatchFlag(props)
}
if (needRuntime) {
runtimeDirectives.push(prop)

View File

@ -76,7 +76,7 @@ export const transformIf = createStructuralDirectiveTransform(
// locate the adjacent v-if
const siblings = context.parent!.children
const comments = []
let i = siblings.indexOf(node as any)
let i = siblings.indexOf(node)
while (i-- >= -1) {
const sibling = siblings[i]
if (__DEV__ && sibling && sibling.type === NodeTypes.COMMENT) {

View File

@ -130,9 +130,9 @@ export function track(
if (depsMap === void 0) {
targetMap.set(target, (depsMap = new Map()))
}
let dep = depsMap.get(key as string | symbol)
let dep = depsMap.get(key!)
if (!dep) {
depsMap.set(key as string | symbol, (dep = new Set()))
depsMap.set(key!, (dep = new Set()))
}
if (!dep.has(effect)) {
dep.add(effect)
@ -170,7 +170,7 @@ export function trigger(
} else {
// schedule runs for SET | ADD | DELETE
if (key !== void 0) {
addRunners(effects, computedRunners, depsMap.get(key as string | symbol))
addRunners(effects, computedRunners, depsMap.get(key))
}
// also run for iteration key on ADD | DELETE
if (type === OperationTypes.ADD || type === OperationTypes.DELETE) {

View File

@ -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]>

View File

@ -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 = {

View File

@ -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
) {

View File

@ -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

View File

@ -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

View File

@ -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[] {