[Vuejs]-DefineEmit in composition API and typecast it properly in my composable

1👍

I think this should do the trick. As your typescript error said, your previous type was not callable. This is.

type EmitType = {
    (event: "search", value: string): void;
};

const emit = defineEmits<EmitType>();

const runEmit = (emit: EmitType) => {
    emit("search", "string");
};

edit:
See https://vuejs.org/guide/typescript/composition-api.html#typing-component-emits

Leave a comment