From 2b3e6c676c433e63d10f903e8c64e309de50cd71 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Thu, 9 Mar 2023 10:58:25 +0100 Subject: [PATCH] refactor: better types --- packages/runtime-core/src/apiInject.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/runtime-core/src/apiInject.ts b/packages/runtime-core/src/apiInject.ts index 65722739135..cb9b89e76a7 100644 --- a/packages/runtime-core/src/apiInject.ts +++ b/packages/runtime-core/src/apiInject.ts @@ -1,8 +1,9 @@ import { isFunction } from '@vue/shared' import { currentInstance } from './component' import { currentRenderingInstance } from './componentRenderContext' -import { App, currentApp } from './apiCreateApp' +import { currentApp } from './apiCreateApp' import { warn } from './warning' +import { ComponentPublicInstance } from './componentPublicInstance' export interface InjectionKey extends Symbol {} @@ -64,7 +65,9 @@ export function inject( return provides[key as string] } else if (arguments.length > 1) { return treatDefaultAsFactory && isFunction(defaultValue) - ? defaultValue.call((instance as App & { proxy: undefined }).proxy) + ? defaultValue.call( + (instance as { proxy?: ComponentPublicInstance | null }).proxy + ) : defaultValue } else if (__DEV__) { warn(`injection "${String(key)}" not found.`)