Skip to content

Commit ae26bff

Browse files
committed
refactor: better types
1 parent 89089b4 commit ae26bff

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/runtime-core/src/apiInject.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { isFunction } from '@vue/shared'
22
import { currentInstance } from './component'
33
import { currentRenderingInstance } from './componentRenderContext'
4-
import { App, currentApp } from './apiCreateApp'
4+
import { currentApp } from './apiCreateApp'
55
import { warn } from './warning'
6+
import { ComponentPublicInstance } from './componentPublicInstance'
67

78
export interface InjectionKey<T> extends Symbol {}
89

@@ -64,7 +65,9 @@ export function inject(
6465
return provides[key as string]
6566
} else if (arguments.length > 1) {
6667
return treatDefaultAsFactory && isFunction(defaultValue)
67-
? defaultValue.call((instance as App & { proxy: undefined }).proxy)
68+
? defaultValue.call(
69+
(instance as { proxy?: ComponentPublicInstance | null }).proxy
70+
)
6871
: defaultValue
6972
} else if (__DEV__) {
7073
warn(`injection "${String(key)}" not found.`)

0 commit comments

Comments
 (0)