From 1cfa2da78a3933eb22d14fe77f1e2674ce9dacbf Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 13 Aug 2019 11:17:55 -0400 Subject: [PATCH] types: allow string keys in provide/inject --- packages/runtime-core/src/apiInject.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/runtime-core/src/apiInject.ts b/packages/runtime-core/src/apiInject.ts index 79121ec2fd..f3133fb5a9 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) } } -- 2.47.3