Skip to content

Commit 881356b

Browse files
committed
fix(runtime-core): type refs and el backdoor issue for this type
1 parent ed01d92 commit 881356b

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

packages-private/dts-test/defineComponent.test-d.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,6 +1804,35 @@ describe('__typeEmits backdoor, call signature syntax', () => {
18041804
c.$emit('update', 123)
18051805
})
18061806

1807+
describe('__typeRefs backdoor, for this type', () => {
1808+
type Refs = {
1809+
foo: number
1810+
}
1811+
defineComponent({
1812+
__typeRefs: {} as { child: ComponentInstance<typeof Child> },
1813+
mounted() {
1814+
expectType<ComponentInstance<typeof Child>>(this.$refs.child)
1815+
},
1816+
})
1817+
const Child = defineComponent({
1818+
__typeRefs: {} as Refs,
1819+
methods: {
1820+
test() {
1821+
expectType<number>(this.$refs.foo)
1822+
},
1823+
},
1824+
})
1825+
})
1826+
1827+
describe('__typeEl backdoor, for this type', () => {
1828+
defineComponent({
1829+
__typeEl: {} as HTMLAnchorElement,
1830+
mounted() {
1831+
expectType<HTMLAnchorElement>(this.$el)
1832+
},
1833+
})
1834+
})
1835+
18071836
describe('__typeRefs backdoor, object syntax', () => {
18081837
type Refs = {
18091838
foo: number

packages/runtime-core/src/apiDefineComponent.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ export function defineComponent<
272272
Slots,
273273
LocalComponents,
274274
Directives,
275-
Exposed
275+
Exposed,
276+
TypeRefs,
277+
TypeEl
276278
>
277279
>,
278280
): DefineComponent<

0 commit comments

Comments
 (0)