In Vue 3, it is now possible to write components in TypeScript:
/// modal.vue
<template>
<div class="modal"></div>
</template>
<script lang="ts">
import { defineComponent } from "vue";
export default defineComponent({
name: "Modal",
props: {
foo: String,
bar: String
},
mounted() {
this.$props.foo // how to type `this` out of this context?
}
});
</script>
I am curious about how to properly type the vue instance outside of the defineComponent
function?
/// another ts file.
let modal:???; // what should be used in place of `???`?
modal.$props.foo // make correct inference for `$props.foo`