From 2b93e86aa1437168476cbb5100cfb3bbbac55efa Mon Sep 17 00:00:00 2001 From: WORMSS Date: Fri, 16 Apr 2021 16:59:37 +0100 Subject: [PATCH] fix(types): make $refs undefined possible (#11112) Added undefined as a return type of $refs as it was quite hard to convince typescript that something COULD be undefined if you type in a ref that doesn't exist, I also changed the two array statements from `Element[] | Vue[]` to `(Element | Vue)[]` because it's not guaranteed that they are ALL Elements or they are ALL Vue components. (Very likely, yes, but not always) For example ```html ``` --- types/vue.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/vue.d.ts b/types/vue.d.ts index 574d50a6df1..7adb5a53aec 100644 --- a/types/vue.d.ts +++ b/types/vue.d.ts @@ -26,7 +26,7 @@ export interface Vue { readonly $parent: Vue; readonly $root: Vue; readonly $children: Vue[]; - readonly $refs: { [key: string]: Vue | Element | Vue[] | Element[] }; + readonly $refs: { [key: string]: Vue | Element | (Vue | Element)[] | undefined }; readonly $slots: { [key: string]: VNode[] | undefined }; readonly $scopedSlots: { [key: string]: NormalizedScopedSlot | undefined }; readonly $isServer: boolean;