Skip to content

Commit

Permalink
fix(runtime-core): type refs and el backdoor issue for this type
Browse files Browse the repository at this point in the history
  • Loading branch information
gcaaa31928 committed Oct 18, 2024
1 parent 657603d commit b8b9fdf
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
33 changes: 33 additions & 0 deletions packages-private/dts-test/defineComponent.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1804,6 +1804,39 @@ describe('__typeEmits backdoor, call signature syntax', () => {
c.$emit('update', 123)
})

describe('__typeRefs backdoor, for this type', () => {
type Refs = {
foo: number
}
defineComponent({
__typeRefs: {} as { child: ComponentInstance<typeof Child> },
methods: {
test() {
expectType<ComponentInstance<typeof Child>>(this.$refs.child)
},
},
})
const Child = defineComponent({
__typeRefs: {} as Refs,
methods: {
test() {
expectType<number>(this.$refs.foo)
},
},
})
})

describe('__typeEl backdoor, for this type', () => {
defineComponent({
__typeEl: {} as HTMLAnchorElement,
methods: {
test() {
expectType<HTMLAnchorElement>(this.$el)
},
},
})
})

describe('__typeRefs backdoor, object syntax', () => {
type Refs = {
foo: number
Expand Down
4 changes: 3 additions & 1 deletion packages/runtime-core/src/apiDefineComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ export function defineComponent<
Slots,
LocalComponents,
Directives,
Exposed
Exposed,
TypeRefs,
TypeEl
>
>,
): DefineComponent<
Expand Down

0 comments on commit b8b9fdf

Please sign in to comment.