import type { VNode } from './vnode'
import type { ComponentInternalInstance } from './component'
import { popWarningContext, pushWarningContext, warn } from './warning'
-import { isFunction, isPromise } from '@vue/shared'
+import { isArray, isFunction, isPromise } from '@vue/shared'
import { LifecycleHooks } from './enums'
// contexts where user provided function may be executed, in addition to
instance: ComponentInternalInstance | null,
type: ErrorTypes,
args?: unknown[],
-): any[] {
+): any {
if (isFunction(fn)) {
const res = callWithErrorHandling(fn, instance, type, args)
if (res && isPromise(res)) {
return res
}
- const values = []
- for (let i = 0; i < fn.length; i++) {
- values.push(callWithAsyncErrorHandling(fn[i], instance, type, args))
+ if (isArray(fn)) {
+ const values = []
+ for (let i = 0; i < fn.length; i++) {
+ values.push(callWithAsyncErrorHandling(fn[i], instance, type, args))
+ }
+ return values
+ } else if (__DEV__) {
+ warn(
+ `Invalid value type passed to callWithAsyncErrorHandling(): ${typeof fn}`,
+ )
}
- return values
}
export function handleError(