Skip to content

Commit 9ed6847

Browse files
committed
test: add test for type casting $refs to defineComponent instance type
1 parent fffbb9e commit 9ed6847

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

types/test/v3/define-component-test.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,14 @@ defineComponent({
11391139
}
11401140
})
11411141

1142+
const X = defineComponent({
1143+
methods: {
1144+
foo() {
1145+
return 123
1146+
}
1147+
}
1148+
})
1149+
11421150
// Missing / mismatching Vue 2 properties
11431151
// https://github.com/vuejs/vue/issues/12628#issuecomment-1177258223
11441152
defineComponent({
@@ -1149,6 +1157,11 @@ defineComponent({
11491157
this.$ssrContext
11501158
this.$isServer
11511159
this.$children[0].$root.$children
1160+
1161+
// type casting refs
1162+
const foo = this.$refs.foo as InstanceType<typeof X>
1163+
foo.foo().toExponential()
1164+
11521165
return h('div', {}, [...this.$slots.default!])
11531166
}
11541167
})

0 commit comments

Comments
 (0)