Skip to content

Commit fbabae0

Browse files
pikaxyyx990803
authored andcommitted
chore: replace some type casts and fix variable and filename typos (vuejs#93)
1 parent 23ff681 commit fbabae0

File tree

10 files changed

+51
-51
lines changed

10 files changed

+51
-51
lines changed

packages/compiler-core/src/transform.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export type DirectiveTransform = (
3939
needRuntime: boolean
4040
}
4141

42-
// A structural directive transform is a techically a NodeTransform;
42+
// A structural directive transform is a technically a NodeTransform;
4343
// Only v-if and v-for fall into this category.
4444
export type StructuralDirectiveTransform = (
4545
node: ElementNode,
@@ -191,11 +191,11 @@ function createTransformContext(
191191
if (identifiers[id] === undefined) {
192192
identifiers[id] = 0
193193
}
194-
;(identifiers[id] as number)++
194+
identifiers[id]!++
195195
}
196196

197197
function removeId(id: string) {
198-
;(context.identifiers[id] as number)--
198+
context.identifiers[id]!--
199199
}
200200

201201
return context

packages/compiler-core/src/transforms/transformElement.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export function buildProps(
191191
let hasDynamicKeys = false
192192
const dynamicPropNames: string[] = []
193193

194-
const anaylizePatchFlag = ({ key, value }: Property) => {
194+
const analyzePatchFlag = ({ key, value }: Property) => {
195195
if (key.type === NodeTypes.SIMPLE_EXPRESSION && key.isStatic) {
196196
if (value.type !== NodeTypes.SIMPLE_EXPRESSION || !value.isStatic) {
197197
const name = key.content
@@ -288,10 +288,10 @@ export function buildProps(
288288
const { props, needRuntime } = directiveTransform(prop, context)
289289
if (isArray(props)) {
290290
properties.push(...props)
291-
properties.forEach(anaylizePatchFlag)
291+
properties.forEach(analyzePatchFlag)
292292
} else {
293293
properties.push(props)
294-
anaylizePatchFlag(props)
294+
analyzePatchFlag(props)
295295
}
296296
if (needRuntime) {
297297
runtimeDirectives.push(prop)

packages/compiler-core/src/transforms/vIf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const transformIf = createStructuralDirectiveTransform(
7676
// locate the adjacent v-if
7777
const siblings = context.parent!.children
7878
const comments = []
79-
let i = siblings.indexOf(node as any)
79+
let i = siblings.indexOf(node)
8080
while (i-- >= -1) {
8181
const sibling = siblings[i]
8282
if (__DEV__ && sibling && sibling.type === NodeTypes.COMMENT) {

packages/reactivity/src/effect.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ export function track(
130130
if (depsMap === void 0) {
131131
targetMap.set(target, (depsMap = new Map()))
132132
}
133-
let dep = depsMap.get(key as string | symbol)
133+
let dep = depsMap.get(key!)
134134
if (!dep) {
135-
depsMap.set(key as string | symbol, (dep = new Set()))
135+
depsMap.set(key!, (dep = new Set()))
136136
}
137137
if (!dep.has(effect)) {
138138
dep.add(effect)
@@ -170,7 +170,7 @@ export function trigger(
170170
} else {
171171
// schedule runs for SET | ADD | DELETE
172172
if (key !== void 0) {
173-
addRunners(effects, computedRunners, depsMap.get(key as string | symbol))
173+
addRunners(effects, computedRunners, depsMap.get(key))
174174
}
175175
// also run for iteration key on ADD | DELETE
176176
if (type === OperationTypes.ADD || type === OperationTypes.DELETE) {

packages/runtime-core/src/apiOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export interface MethodOptions {
110110
[key: string]: Function
111111
}
112112

113-
export type ExtracComputedReturns<T extends any> = {
113+
export type ExtractComputedReturns<T extends any> = {
114114
[key in keyof T]: T[key] extends { get: Function }
115115
? ReturnType<T[key]['get']>
116116
: ReturnType<T[key]>

packages/runtime-core/src/componentProxy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ComponentInternalInstance, Data } from './component'
22
import { nextTick } from './scheduler'
33
import { instanceWatch } from './apiWatch'
44
import { EMPTY_OBJ, hasOwn, globalsWhitelist } from '@vue/shared'
5-
import { ExtracComputedReturns } from './apiOptions'
5+
import { ExtractComputedReturns } from './apiOptions'
66
import { UnwrapRef } from '@vue/reactivity'
77

88
// public properties exposed on the proxy, which is used as the render context
@@ -26,7 +26,7 @@ export type ComponentPublicInstance<
2626
} & P &
2727
UnwrapRef<B> &
2828
D &
29-
ExtracComputedReturns<C> &
29+
ExtractComputedReturns<C> &
3030
M
3131

3232
export const PublicInstanceProxyHandlers = {

packages/runtime-core/src/createRenderer.ts

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export function createRenderer<
149149
} {
150150
type HostVNode = VNode<HostNode, HostElement>
151151
type HostVNodeChildren = VNodeChildren<HostNode, HostElement>
152-
type HostSuspsenseBoundary = SuspenseBoundary<HostNode, HostElement>
152+
type HostSuspenseBoundary = SuspenseBoundary<HostNode, HostElement>
153153

154154
const {
155155
insert: hostInsert,
@@ -171,7 +171,7 @@ export function createRenderer<
171171
container: HostElement,
172172
anchor: HostNode | null = null,
173173
parentComponent: ComponentInternalInstance | null = null,
174-
parentSuspense: HostSuspsenseBoundary | null = null,
174+
parentSuspense: HostSuspenseBoundary | null = null,
175175
isSVG: boolean = false,
176176
optimized: boolean = false
177177
) {
@@ -303,7 +303,7 @@ export function createRenderer<
303303
container: HostElement,
304304
anchor: HostNode | null,
305305
parentComponent: ComponentInternalInstance | null,
306-
parentSuspense: HostSuspsenseBoundary | null,
306+
parentSuspense: HostSuspenseBoundary | null,
307307
isSVG: boolean,
308308
optimized: boolean
309309
) {
@@ -329,7 +329,7 @@ export function createRenderer<
329329
container: HostElement,
330330
anchor: HostNode | null,
331331
parentComponent: ComponentInternalInstance | null,
332-
parentSuspense: HostSuspsenseBoundary | null,
332+
parentSuspense: HostSuspenseBoundary | null,
333333
isSVG: boolean
334334
) {
335335
const tag = vnode.type as string
@@ -370,7 +370,7 @@ export function createRenderer<
370370
container: HostElement,
371371
anchor: HostNode | null,
372372
parentComponent: ComponentInternalInstance | null,
373-
parentSuspense: HostSuspsenseBoundary | null,
373+
parentSuspense: HostSuspenseBoundary | null,
374374
isSVG: boolean,
375375
start: number = 0
376376
) {
@@ -392,7 +392,7 @@ export function createRenderer<
392392
n1: HostVNode,
393393
n2: HostVNode,
394394
parentComponent: ComponentInternalInstance | null,
395-
parentSuspense: HostSuspsenseBoundary | null,
395+
parentSuspense: HostSuspenseBoundary | null,
396396
isSVG: boolean,
397397
optimized: boolean
398398
) {
@@ -491,10 +491,10 @@ export function createRenderer<
491491

492492
if (dynamicChildren != null) {
493493
// children fast path
494-
const olddynamicChildren = n1.dynamicChildren!
494+
const oldDynamicChildren = n1.dynamicChildren!
495495
for (let i = 0; i < dynamicChildren.length; i++) {
496496
patch(
497-
olddynamicChildren[i],
497+
oldDynamicChildren[i],
498498
dynamicChildren[i],
499499
el,
500500
null,
@@ -522,7 +522,7 @@ export function createRenderer<
522522
oldProps: any,
523523
newProps: any,
524524
parentComponent: ComponentInternalInstance | null,
525-
parentSuspense: HostSuspsenseBoundary | null,
525+
parentSuspense: HostSuspenseBoundary | null,
526526
isSVG: boolean
527527
) {
528528
if (oldProps !== newProps) {
@@ -571,7 +571,7 @@ export function createRenderer<
571571
container: HostElement,
572572
anchor: HostNode | null,
573573
parentComponent: ComponentInternalInstance | null,
574-
parentSuspense: HostSuspsenseBoundary | null,
574+
parentSuspense: HostSuspenseBoundary | null,
575575
isSVG: boolean,
576576
optimized: boolean
577577
) {
@@ -613,7 +613,7 @@ export function createRenderer<
613613
container: HostElement,
614614
anchor: HostNode | null,
615615
parentComponent: ComponentInternalInstance | null,
616-
parentSuspense: HostSuspsenseBoundary | null,
616+
parentSuspense: HostSuspenseBoundary | null,
617617
isSVG: boolean,
618618
optimized: boolean
619619
) {
@@ -685,7 +685,7 @@ export function createRenderer<
685685
container: HostElement,
686686
anchor: HostNode | null,
687687
parentComponent: ComponentInternalInstance | null,
688-
parentSuspense: HostSuspsenseBoundary | null,
688+
parentSuspense: HostSuspenseBoundary | null,
689689
isSVG: boolean,
690690
optimized: boolean
691691
) {
@@ -717,7 +717,7 @@ export function createRenderer<
717717
container: HostElement,
718718
anchor: HostNode | null,
719719
parentComponent: ComponentInternalInstance | null,
720-
parentSuspense: HostSuspsenseBoundary | null,
720+
parentSuspense: HostSuspenseBoundary | null,
721721
isSVG: boolean,
722722
optimized: boolean
723723
) {
@@ -828,7 +828,7 @@ export function createRenderer<
828828
suspense.fallbackTree = fallback
829829
}
830830

831-
function resolveSuspense(suspense: HostSuspsenseBoundary) {
831+
function resolveSuspense(suspense: HostSuspenseBoundary) {
832832
if (__DEV__) {
833833
if (suspense.isResolved) {
834834
throw new Error(
@@ -861,7 +861,7 @@ export function createRenderer<
861861
}
862862
// move content from off-dom container to actual container
863863
move(subTree as HostVNode, container, anchor)
864-
const el = (vnode.el = (subTree as HostVNode).el as HostNode)
864+
const el = (vnode.el = (subTree as HostVNode).el!)
865865
// suspense as the root node of a component...
866866
if (parentComponent && parentComponent.subTree === vnode) {
867867
parentComponent.vnode.el = el
@@ -892,7 +892,7 @@ export function createRenderer<
892892
}
893893
}
894894

895-
function restartSuspense(suspense: HostSuspsenseBoundary) {
895+
function restartSuspense(suspense: HostSuspenseBoundary) {
896896
suspense.isResolved = false
897897
const {
898898
vnode,
@@ -919,7 +919,7 @@ export function createRenderer<
919919
isSVG,
920920
optimized
921921
)
922-
const el = (vnode.el = (fallbackTree as HostVNode).el as HostNode)
922+
const el = (vnode.el = (fallbackTree as HostVNode).el!)
923923
// suspense as the root node of a component...
924924
if (parentComponent && parentComponent.subTree === vnode) {
925925
parentComponent.vnode.el = el
@@ -939,7 +939,7 @@ export function createRenderer<
939939
container: HostElement,
940940
anchor: HostNode | null,
941941
parentComponent: ComponentInternalInstance | null,
942-
parentSuspense: HostSuspsenseBoundary | null,
942+
parentSuspense: HostSuspenseBoundary | null,
943943
isSVG: boolean,
944944
optimized: boolean
945945
) {
@@ -993,7 +993,7 @@ export function createRenderer<
993993
container: HostElement,
994994
anchor: HostNode | null,
995995
parentComponent: ComponentInternalInstance | null,
996-
parentSuspense: HostSuspsenseBoundary | null,
996+
parentSuspense: HostSuspenseBoundary | null,
997997
isSVG: boolean
998998
) {
999999
const instance: ComponentInternalInstance = (initialVNode.component = createComponentInstance(
@@ -1073,7 +1073,7 @@ export function createRenderer<
10731073
function retryAsyncComponent(
10741074
instance: ComponentInternalInstance,
10751075
asyncSetupResult: unknown,
1076-
parentSuspense: HostSuspsenseBoundary,
1076+
parentSuspense: HostSuspenseBoundary,
10771077
isSVG: boolean
10781078
) {
10791079
parentSuspense.deps--
@@ -1104,7 +1104,7 @@ export function createRenderer<
11041104

11051105
function setupRenderEffect(
11061106
instance: ComponentInternalInstance,
1107-
parentSuspense: HostSuspsenseBoundary | null,
1107+
parentSuspense: HostSuspenseBoundary | null,
11081108
initialVNode: HostVNode,
11091109
container: HostElement,
11101110
anchor: HostNode | null,
@@ -1168,7 +1168,7 @@ export function createRenderer<
11681168
// to child component's vnode
11691169
updateHOCHostEl(instance, nextTree.el)
11701170
}
1171-
// upated hook
1171+
// updated hook
11721172
if (instance.u !== null) {
11731173
queuePostRenderEffect(instance.u, parentSuspense)
11741174
}
@@ -1207,7 +1207,7 @@ export function createRenderer<
12071207
container: HostElement,
12081208
anchor: HostNode | null,
12091209
parentComponent: ComponentInternalInstance | null,
1210-
parentSuspense: HostSuspsenseBoundary | null,
1210+
parentSuspense: HostSuspenseBoundary | null,
12111211
isSVG: boolean,
12121212
optimized: boolean = false
12131213
) {
@@ -1311,7 +1311,7 @@ export function createRenderer<
13111311
container: HostElement,
13121312
anchor: HostNode | null,
13131313
parentComponent: ComponentInternalInstance | null,
1314-
parentSuspense: HostSuspsenseBoundary | null,
1314+
parentSuspense: HostSuspenseBoundary | null,
13151315
isSVG: boolean,
13161316
optimized: boolean
13171317
) {
@@ -1358,7 +1358,7 @@ export function createRenderer<
13581358
container: HostElement,
13591359
parentAnchor: HostNode | null,
13601360
parentComponent: ComponentInternalInstance | null,
1361-
parentSuspense: HostSuspsenseBoundary | null,
1361+
parentSuspense: HostSuspenseBoundary | null,
13621362
isSVG: boolean,
13631363
optimized: boolean
13641364
) {
@@ -1464,7 +1464,7 @@ export function createRenderer<
14641464
const s2 = i // next starting index
14651465

14661466
// 5.1 build key:index map for newChildren
1467-
const keyToNewIndexMap: Map<any, number> = new Map()
1467+
const keyToNewIndexMap: Map<string | number, number> = new Map()
14681468
for (i = s2; i <= e2; i++) {
14691469
const nextChild = (c2[i] = normalizeVNode(c2[i]))
14701470
if (nextChild.key != null) {
@@ -1613,7 +1613,7 @@ export function createRenderer<
16131613
function unmount(
16141614
vnode: HostVNode,
16151615
parentComponent: ComponentInternalInstance | null,
1616-
parentSuspense: HostSuspsenseBoundary | null,
1616+
parentSuspense: HostSuspenseBoundary | null,
16171617
doRemove?: boolean
16181618
) {
16191619
const {
@@ -1678,7 +1678,7 @@ export function createRenderer<
16781678

16791679
function unmountComponent(
16801680
instance: ComponentInternalInstance,
1681-
parentSuspense: HostSuspsenseBoundary | null,
1681+
parentSuspense: HostSuspenseBoundary | null,
16821682
doRemove?: boolean
16831683
) {
16841684
const { bum, effects, update, subTree, um } = instance
@@ -1724,9 +1724,9 @@ export function createRenderer<
17241724
}
17251725

17261726
function unmountSuspense(
1727-
suspense: HostSuspsenseBoundary,
1727+
suspense: HostSuspenseBoundary,
17281728
parentComponent: ComponentInternalInstance | null,
1729-
parentSuspense: HostSuspsenseBoundary | null,
1729+
parentSuspense: HostSuspenseBoundary | null,
17301730
doRemove?: boolean
17311731
) {
17321732
suspense.isUnmounted = true
@@ -1739,7 +1739,7 @@ export function createRenderer<
17391739
function unmountChildren(
17401740
children: HostVNode[],
17411741
parentComponent: ComponentInternalInstance | null,
1742-
parentSuspense: HostSuspsenseBoundary | null,
1742+
parentSuspense: HostSuspenseBoundary | null,
17431743
doRemove?: boolean,
17441744
start: number = 0
17451745
) {

packages/runtime-core/src/errorHandling.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export function handleError(
8686
) {
8787
const contextVNode = instance ? instance.vnode : null
8888
if (instance) {
89-
let cur: ComponentInternalInstance | null = instance.parent
89+
let cur = instance.parent
9090
// the exposed instance is the render proxy to keep it consistent with 2.x
9191
const exposedInstance = instance.renderProxy
9292
// in production the hook receives only the error code

packages/runtime-core/src/vnode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ const blockStack: (VNode[] | null)[] = []
9797
//
9898
// disableTracking is true when creating a fragment block, since a fragment
9999
// always diffs its children.
100-
export function openBlock(disableTrackng?: boolean) {
101-
blockStack.push(disableTrackng ? null : [])
100+
export function openBlock(disableTracking?: boolean) {
101+
blockStack.push(disableTracking ? null : [])
102102
}
103103

104104
let shouldTrack = true

0 commit comments

Comments
 (0)