types(@vant/use): useRelation support InjectionKey (#9015)

This commit is contained in:
neverland
2021-07-12 20:40:30 +08:00
committed by GitHub
parent c2737446a6
commit f0a5931b6e
2 changed files with 9 additions and 5 deletions
@@ -3,6 +3,7 @@ import {
inject,
computed,
onUnmounted,
InjectionKey,
getCurrentInstance,
ComponentPublicInstance,
ComponentInternalInstance,
@@ -15,8 +16,8 @@ type ParentProvide<T> = T & {
internalChildren: ComponentInternalInstance[];
};
export function useParent<T>(key: string | symbol) {
const parent = inject<ParentProvide<T> | null>(key, null);
export function useParent<T>(key: InjectionKey<ParentProvide<T>>) {
const parent = inject(key, null);
if (parent) {
const instance = getCurrentInstance()!;