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 Nov 4, 2024
1 parent 76c43c6 commit fd22d0e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
29 changes: 29 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,35 @@ 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> },
mounted() {
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,
mounted() {
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 fd22d0e

Please sign in to comment.