]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: replace some type casts and fix variable and filename typos (#93)
authorCarlos Rodrigues <david-181@hotmail.com>
Sat, 5 Oct 2019 14:38:02 +0000 (15:38 +0100)
committerEvan You <yyx990803@gmail.com>
Sat, 5 Oct 2019 14:38:02 +0000 (10:38 -0400)
packages/compiler-core/src/transform.ts
packages/compiler-core/src/transforms/transformElement.ts
packages/compiler-core/src/transforms/vIf.ts
packages/reactivity/src/effect.ts
packages/runtime-core/src/apiOptions.ts
packages/runtime-core/src/componentProxy.ts
packages/runtime-core/src/createRenderer.ts
packages/runtime-core/src/errorHandling.ts
packages/runtime-core/src/vnode.ts
packages/runtime-core/src/warning.ts

index 5577f009ab811bd9c114ca5c4001c894c97dabbc..b995014f47ad88f16b3deeb8ca796eb410311bb7 100644 (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
index 654b8775a76d38887b94af197f5f6ace478d2e44..513a788b612e954bfe482fdcc12c6f51df129045 100644 (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)
index 25700c34c4351a26ea97e296fcd64ba0e8ab5bf3..7d09767c5367e682305223f0a9cf04578ed77f5a 100644 (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) {
index 76ff3f1e6237e29b96dfc521617a829deaaa8462..5284825ce222b2b977109b048a6e8e4391f26cc6 100644 (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) {
index 8f8582e33d178f15773fa84292b4dc1228503b02..643da77750a83443e90baeaf770d60c9d7ec0ea4 100644 (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]>
index b93e5aba34445a6d223407c2c2e8a10dbb26e736..49727b3593257556fcb61c575f03b9bbf82041d4 100644 (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 = {
index 83d98f18f55961bf07712bcc41f857fe075f02ba..00280955cff4516580d2113e6fb742f5143b9497 100644 (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
   ) {
index 26a99a26924e9798eaa53a0bc1e9271f128ef585..fbe78cca68f74f2718e56ed94e67f9f678afac6d 100644 (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
index f0090ffb87fa7b2727146c1d9604aa0b75cbda89..3a74985c715ad7dd1a532f79d2c23a102da1f772 100644 (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
index 4aede5e85ebf464b89bd5a5df772a26f234d315f..4ae71f95a6e8429f479b9dafda1142b6d57c4509 100644 (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[] {