Skip to content

Commit

Permalink
fix(types): allow string keys in provide/inject
Browse files Browse the repository at this point in the history
Resolves: #56
  • Loading branch information
liximomo committed Aug 15, 2019
1 parent 62bb55b commit e86b855
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/functions/inject.ts
Expand Up @@ -23,8 +23,8 @@ function resolveInject(provideKey: Key<any>, vm: Vue): any {
}

export function provide(data: AnyObject): void;
export function provide<T>(key: Key<T>, value: T | Wrapper<T>): void;
export function provide<T>(keyOrData: Key<T> | AnyObject, value?: T | Wrapper<T>): void {
export function provide<T>(key: Key<T> | string, value: T | Wrapper<T>): void;
export function provide<T>(keyOrData: Key<T> | string | AnyObject, value?: T | Wrapper<T>): void {
const vm: any = ensureCurrentVMInFn('provide');
if (!vm._provided) {
vm._provided = {};
Expand All @@ -37,13 +37,13 @@ export function provide<T>(keyOrData: Key<T> | AnyObject, value?: T | Wrapper<T>
}
}

export function inject<T>(key: Key<T>): Wrapper<T> | void {
export function inject<T>(key: Key<T> | string): Wrapper<T> | void {
if (!key) {
return;
}

const vm = ensureCurrentVMInFn('inject');
const val = resolveInject(key, vm);
const val = resolveInject(key as Key<T>, vm);
if (val !== UNRESOLVED_INJECT) {
if (isWrapper<T>(val)) {
return val;
Expand Down

0 comments on commit e86b855

Please sign in to comment.