From c2513c5934ef0b586bd09f9d57fc482dd0fec73f Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Sun, 23 Aug 2020 15:40:34 +0800 Subject: [PATCH] types: improve use relation typing --- src/api/use-relation.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/use-relation.ts b/src/api/use-relation.ts index 5ab204708..d7ab9a027 100644 --- a/src/api/use-relation.ts +++ b/src/api/use-relation.ts @@ -1,7 +1,7 @@ import { ref, Ref, provide, inject, computed, onUnmounted } from 'vue'; -export type Parent = null | { - children: Ref; +export type Parent = null | { + children: Ref[]>; }; export function useChildren(key: string) { @@ -10,8 +10,8 @@ export function useChildren(key: string) { return children; } -export function useParent(key: string, child: unknown) { - const parent = inject(key, null); +export function useParent(key: string, child: Ref) { + const parent = inject>(key, null); if (parent) { const children = parent.children.value;