I want to use emit in my following file: useGoo.ts
import Swal from "sweetalert2/dist/sweetalert2.js";
export default function useModal() {
const { emit } = getCurrentInstance();
function myId() {
emit('id', '123')
}
}
But the emit does not work ofcourse. Can't get it working. Error:
Property 'emit' does not exist on type 'ComponentInternalInstance | null'
As I'm using TypeScript. The solution is as following: const { emit } = getCurrentInstance() as any;