diff --git a/packages/runtime-core/src/apiInject.ts b/packages/runtime-core/src/apiInject.ts index 79121ec2..f3133fb5 100644 --- a/packages/runtime-core/src/apiInject.ts +++ b/packages/runtime-core/src/apiInject.ts @@ -3,7 +3,7 @@ import { currentInstance } from './component' export interface Key extends Symbol {} -export function provide(key: Key, value: T | Value) { +export function provide(key: Key | string, value: T | Value) { if (!currentInstance) { // TODO warn } else { @@ -22,14 +22,14 @@ export function provide(key: Key, value: T | Value) { } } -export function inject(key: Key): Value | undefined { +export function inject(key: Key | string): Value | undefined { if (!currentInstance) { // TODO warn } else { // TODO should also check for app-level provides const provides = currentInstance.parent && currentInstance.provides if (provides) { - const val = provides[key as any] + const val = provides[key as any] as any return isValue(val) ? val : value(val) } }