Skip to content

Commit ebb7975

Browse files
authored
fix(type): remove unnecessary type assertion (#766)
Co-authored-by: webfansplz <>
1 parent d7de23e commit ebb7975

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

src/apis/createElement.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ export const createElement = function createElement(...args: any) {
2222
}
2323

2424
return instance.$createElement.apply(instance, args)
25-
} as any as CreateElement
25+
} as CreateElement

src/apis/lifecycle.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function injectHookOption(
2323
hook: string,
2424
val: Function
2525
) {
26-
const options = vm.$options as any
26+
const options = vm.$options as Record<string, unknown>
2727
const mergeFn = Vue.config.optionMergeStrategies[hook]
2828
options[hook] = mergeFn(options[hook], wrapHookCall(vm, val))
2929
}

src/apis/nextTick.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export const nextTick: NextTick = function nextTick(
88
...args: Parameters<NextTick>
99
) {
1010
return getVueConstructor()?.nextTick.apply(this, args)
11-
} as any
11+
}

src/apis/watch.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ function createWatcher(
255255
fn(...args)
256256
},
257257
flushMode as 'pre' | 'post'
258-
)) as any as T
258+
)) as unknown as T
259259
}
260260

261261
// effect watch
@@ -471,7 +471,7 @@ function traverse(value: unknown, seen: Set<unknown> = new Set()) {
471471
})
472472
} else if (isPlainObject(value)) {
473473
for (const key in value) {
474-
traverse((value as any)[key], seen)
474+
traverse(value[key], seen)
475475
}
476476
}
477477
return value

src/reactivity/reactive.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,20 @@ export function createObserver() {
171171
}
172172

173173
export function shallowReactive<T extends object = any>(obj: T): T
174-
export function shallowReactive(obj: any): any {
174+
export function shallowReactive(obj: any) {
175175
if (!isObject(obj)) {
176176
if (__DEV__) {
177177
warn('"shallowReactive()" must be called on an object.')
178178
}
179-
return obj as any
179+
return obj
180180
}
181181

182182
if (
183183
!(isPlainObject(obj) || isArray(obj)) ||
184184
isRaw(obj) ||
185185
!Object.isExtensible(obj)
186186
) {
187-
return obj as any
187+
return obj
188188
}
189189

190190
const observed = observe(isArray(obj) ? [] : {})
@@ -233,7 +233,7 @@ export function reactive<T extends object>(obj: T): UnwrapRef<T> {
233233
if (__DEV__) {
234234
warn('"reactive()" must be called on an object.')
235235
}
236-
return obj as any
236+
return obj
237237
}
238238

239239
if (

src/reactivity/ref.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export function toRefs<T extends object>(obj: T): ToRefs<T> {
122122
if (__DEV__ && !isReactive(obj)) {
123123
warn(`toRefs() expects a reactive object but received a plain one.`)
124124
}
125-
if (!isPlainObject(obj)) return obj as any
125+
if (!isPlainObject(obj)) return obj
126126

127127
const ret: any = {}
128128
for (const key in obj) {

src/runtimeContext.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ function toVue3ComponentInstance(
168168
return instanceMapCache.get(vue2Instance)!
169169
}
170170

171-
const instance: ComponentInternalInstance = ({
171+
const instance: ComponentInternalInstance = {
172172
proxy: vue2Instance,
173173
update: vue2Instance.$forceUpdate,
174174
uid: vue2Instance._uid,
@@ -177,8 +177,8 @@ function toVue3ComponentInstance(
177177
emit: vue2Instance.$emit.bind(vue2Instance),
178178

179179
parent: null,
180-
root: null as any,
181-
} as unknown) as ComponentInternalInstance
180+
root: null!, // to be immediately set
181+
} as unknown as ComponentInternalInstance
182182

183183
// map vm.$props =
184184
const instanceProps = [

0 commit comments

Comments
 (0)