Composition Api props and emit type declaration
What problem does this feature solve?
// props type: ???
// emit type: ???
function useVisibile(props, emit) {
const visibile = computed({
set(val) {
emit("update:modelValue", val);
},
get() {
return props.modelValue;
}
});
return {
visibile
};
}
What does the proposed API look like?
How to declare props and emit type
Full Code
<script>
import { defineComponent, computed } from "vue";
import ComDialog from "./ComDialog.vue";
// props type: ???
// emit type: ???
function useVisibile(props, emit) {
const visibile = computed({
set(val) {
emit("update:modelValue", val);
},
get() {
return props.modelValue;
}
});
return {
visibile
};
}
export default defineComponent({
name: "HelloWord",
components: {
ComDialog
},
props: {
modelValue: Boolean,
msg: String
},
emits: ["update:"],
setup(props, { emit }) {
const { visibile } = useVisibile(props, emit);
// const visibile = computed({
// set(val) {
// emit("update:modelValue", val);
// },
// get() {
// return props.modelValue;
// }
// });
return {
visibile
};
}
});
</script>