From 9ed684785f868db5b154c4a09642b2b7d33dd6f3 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 15 Jul 2022 17:07:19 +0800 Subject: [PATCH] test: add test for type casting $refs to defineComponent instance type --- types/test/v3/define-component-test.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/types/test/v3/define-component-test.tsx b/types/test/v3/define-component-test.tsx index fde804c400b..42d0f32eb0d 100644 --- a/types/test/v3/define-component-test.tsx +++ b/types/test/v3/define-component-test.tsx @@ -1139,6 +1139,14 @@ defineComponent({ } }) +const X = defineComponent({ + methods: { + foo() { + return 123 + } + } +}) + // Missing / mismatching Vue 2 properties // https://github.com/vuejs/vue/issues/12628#issuecomment-1177258223 defineComponent({ @@ -1149,6 +1157,11 @@ defineComponent({ this.$ssrContext this.$isServer this.$children[0].$root.$children + + // type casting refs + const foo = this.$refs.foo as InstanceType + foo.foo().toExponential() + return h('div', {}, [...this.$slots.default!]) } })