Skip to content

Commit

Permalink
refactor: better types
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Mar 9, 2023
1 parent 89089b4 commit ae26bff
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions 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<T> extends Symbol {}

Expand Down Expand Up @@ -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.`)
Expand Down

0 comments on commit ae26bff

Please sign in to comment.