Skip to content

Commit b8b9fdf

Browse files
committed
fix(runtime-core): type refs and el backdoor issue for this type
1 parent 657603d commit b8b9fdf

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,6 +1804,39 @@ 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+
methods: {
1814+
test() {
1815+
expectType<ComponentInstance<typeof Child>>(this.$refs.child)
1816+
},
1817+
},
1818+
})
1819+
const Child = defineComponent({
1820+
__typeRefs: {} as Refs,
1821+
methods: {
1822+
test() {
1823+
expectType<number>(this.$refs.foo)
1824+
},
1825+
},
1826+
})
1827+
})
1828+
1829+
describe('__typeEl backdoor, for this type', () => {
1830+
defineComponent({
1831+
__typeEl: {} as HTMLAnchorElement,
1832+
methods: {
1833+
test() {
1834+
expectType<HTMLAnchorElement>(this.$el)
1835+
},
1836+
},
1837+
})
1838+
})
1839+
18071840
describe('__typeRefs backdoor, object syntax', () => {
18081841
type Refs = {
18091842
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)