Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS2769: No overload matches this call error when typing component emits using <script setup> #12660

Closed
iraklisg opened this issue Jul 14, 2022 · 0 comments

Comments

@iraklisg
Copy link

iraklisg commented Jul 14, 2022

Version

2.7.5

Reproduction link

github.com

Steps to reproduce

  1. Clone the reproduction repo git clone https://github.com/iraklisg/mix-ts-vue-script-setup.git
  2. Build the assets npm run dev

What is expected?

To build the assets without errors

What is actually happening?

The following TS error occurs

TS2769: No overload matches this call.
The last overload gave the following error.
Type '(this: void, __props: Readonly<Readonly<LooseRequired<{}>>>, { emit }: { emit: (e: "clicked") => void; expose: any; slots: any; attrs: any; }) => { __sfc: boolean; emit: (e: "clicked") => void; }' is not assignable to type 'SetupFunction<Readonly<LooseRequired<{}>>, { __sfc: boolean; emit: (e: "clicked") => void; }, "clicked"[]>'.
Types of parameters '__1' and 'ctx' are incompatible.
Property 'expose' is missing in type 'SetupContext<"clicked"[]>' but required in type '{ emit: (e: "clicked") => void; expose: any; slots: any; attrs: any; }'.

Defining a type literal to be used as the type of the returned emit function results to an error.
Using the defineEmits macro without returning does not produce errors

// This does not produce errors
defineEmits<{
    (e: 'clicked'): void;
}>();


// This produces errors
const emit = defineEmits<{
    (e: 'clicked'): void;
}>();

const doSomething = () => {
    // ...
    emit('clicked');
};

The assets are build using webpack (laravel-mix)

  • Laravel Mix Version: 6.0.49
  • Node Version: 18.1.0
  • NPM Version: 8.8.0:
  • OS: Linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant