diff --git a/packages/compiler-core/src/transform.ts b/packages/compiler-core/src/transform.ts index 5577f009..b995014f 100644 --- a/packages/compiler-core/src/transform.ts +++ b/packages/compiler-core/src/transform.ts @@ -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 diff --git a/packages/compiler-core/src/transforms/transformElement.ts b/packages/compiler-core/src/transforms/transformElement.ts index 654b8775..513a788b 100644 --- a/packages/compiler-core/src/transforms/transformElement.ts +++ b/packages/compiler-core/src/transforms/transformElement.ts @@ -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) diff --git a/packages/compiler-core/src/transforms/vIf.ts b/packages/compiler-core/src/transforms/vIf.ts index 25700c34..7d09767c 100644 --- a/packages/compiler-core/src/transforms/vIf.ts +++ b/packages/compiler-core/src/transforms/vIf.ts @@ -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) { diff --git a/packages/reactivity/src/effect.ts b/packages/reactivity/src/effect.ts index 76ff3f1e..5284825c 100644 --- a/packages/reactivity/src/effect.ts +++ b/packages/reactivity/src/effect.ts @@ -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) { diff --git a/packages/runtime-core/src/apiOptions.ts b/packages/runtime-core/src/apiOptions.ts index 8f8582e3..643da777 100644 --- a/packages/runtime-core/src/apiOptions.ts +++ b/packages/runtime-core/src/apiOptions.ts @@ -110,7 +110,7 @@ export interface MethodOptions { [key: string]: Function } -export type ExtracComputedReturns = { +export type ExtractComputedReturns = { [key in keyof T]: T[key] extends { get: Function } ? ReturnType : ReturnType diff --git a/packages/runtime-core/src/componentProxy.ts b/packages/runtime-core/src/componentProxy.ts index b93e5aba..49727b35 100644 --- a/packages/runtime-core/src/componentProxy.ts +++ b/packages/runtime-core/src/componentProxy.ts @@ -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 & D & - ExtracComputedReturns & + ExtractComputedReturns & M export const PublicInstanceProxyHandlers = { diff --git a/packages/runtime-core/src/createRenderer.ts b/packages/runtime-core/src/createRenderer.ts index 83d98f18..00280955 100644 --- a/packages/runtime-core/src/createRenderer.ts +++ b/packages/runtime-core/src/createRenderer.ts @@ -149,7 +149,7 @@ export function createRenderer< } { type HostVNode = VNode type HostVNodeChildren = VNodeChildren - type HostSuspsenseBoundary = SuspenseBoundary + type HostSuspenseBoundary = SuspenseBoundary 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 = new Map() + const keyToNewIndexMap: Map = 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 ) { diff --git a/packages/runtime-core/src/errorHandling.ts b/packages/runtime-core/src/errorHandling.ts index 26a99a26..fbe78cca 100644 --- a/packages/runtime-core/src/errorHandling.ts +++ b/packages/runtime-core/src/errorHandling.ts @@ -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 diff --git a/packages/runtime-core/src/vnode.ts b/packages/runtime-core/src/vnode.ts index f0090ffb..3a74985c 100644 --- a/packages/runtime-core/src/vnode.ts +++ b/packages/runtime-core/src/vnode.ts @@ -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 diff --git a/packages/runtime-core/src/warning.ts b/packages/runtime-core/src/warning.ts index 4aede5e8..4ae71f95 100644 --- a/packages/runtime-core/src/warning.ts +++ b/packages/runtime-core/src/warning.ts @@ -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[] {