diff --git a/packages/devtools-kit/src/core/component/state/process.ts b/packages/devtools-kit/src/core/component/state/process.ts index 4b7f4bb93..ab18e1bfb 100644 --- a/packages/devtools-kit/src/core/component/state/process.ts +++ b/packages/devtools-kit/src/core/component/state/process.ts @@ -231,11 +231,16 @@ function processProvide(instance: VueAppInstance) { })) } +const hasOwnProperty = Object.prototype.hasOwnProperty +const hasOwn = ( + val: object, + key: string | symbol, +): key is keyof typeof val => hasOwnProperty.call(val, key) + function processInject(instance: VueAppInstance, mergedType: Record) { if (!mergedType?.inject) return [] - let keys: any[] = [] - let defaultValue + let keys: any[] if (Array.isArray(mergedType.inject)) { keys = mergedType.inject.map(key => ({ key, @@ -250,8 +255,7 @@ function processInject(instance: VueAppInstance, mergedType: Record ({ type: 'injected', - key: originalKey && key !== originalKey ? `${originalKey.toString()} ➞ ${key.toString()}` : key.toString(), - // eslint-disable-next-line no-prototype-builtins - value: returnError(() => instance.ctx.hasOwnProperty(key) ? instance.ctx[key] : instance.provides.hasOwnProperty(originalKey) ? instance.provides[originalKey] : defaultValue), + key: key !== originalKey ? `${String(originalKey)} ➞ ${String(key)}` : String(key), + value: returnError(() => hasOwn(instance.ctx, key) ? instance.ctx[key] : undefined), })) }