Skip to content

Commit

Permalink
test: add test for type casting $refs to defineComponent instance type
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jul 15, 2022
1 parent fffbb9e commit 9ed6847
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions types/test/v3/define-component-test.tsx
Expand Up @@ -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({
Expand All @@ -1149,6 +1157,11 @@ defineComponent({
this.$ssrContext
this.$isServer
this.$children[0].$root.$children

// type casting refs
const foo = this.$refs.foo as InstanceType<typeof X>
foo.foo().toExponential()

return h('div', {}, [...this.$slots.default!])
}
})

0 comments on commit 9ed6847

Please sign in to comment.