Skip to content

Commit 9c1c4ca

Browse files
authored
fix: typing component refs (#2210)
1 parent 8f9e959 commit 9c1c4ca

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/guide/typescript/composition-api.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,14 +401,15 @@ defineExpose({
401401
</script>
402402
```
403403

404-
In order to get the instance type of `MyModal`, we need to first get its type via `typeof`, then use TypeScript's built-in `InstanceType` utility to extract its instance type:
404+
In order to get the instance type of `MyModal`, we need to first get its type via `typeof`, then use Vue's `ComponentPublicInstance` utility to extract its instance type:
405405

406406
```vue{5}
407407
<!-- App.vue -->
408408
<script setup lang="ts">
409+
import { ComponentPublicInstance } from 'vue';
409410
import MyModal from './MyModal.vue'
410411
411-
const modal = ref<InstanceType<typeof MyModal> | null>(null)
412+
const modal = ref<ComponentPublicInstance<typeof MyModal> | null>(null)
412413
413414
const openModal = () => {
414415
modal.value?.open()

0 commit comments

Comments
 (0)