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

Typescript: incompatible "this" in component when adding emits #3599

Closed
danielvy opened this issue Apr 13, 2021 · 1 comment · Fixed by #3608
Closed

Typescript: incompatible "this" in component when adding emits #3599

danielvy opened this issue Apr 13, 2021 · 1 comment · Fixed by #3608
Labels
🐞 bug Something isn't working scope: types

Comments

@danielvy
Copy link

Version

3.0.11

Reproduction link

https://github.com/danielvy/vue-emits.git

Steps to reproduce

run npm run build

See App.vue

What is expected?

Typescript project should compile.

What is actually happening?

Typescript reports an error:

TS2684: The 'this' context of type 'ComponentPublicInstance<{}, {}, {}, {}, { test(): void; }, "test"[], {}, {}, false, ComponentOptionsBase<{}, {}, void, {}, { test(): void; }, ComponentOptionsMixin, ComponentOptionsMixin, "test"[], string, {}>>' is not assignable to method's 'this' of type 'void | ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>'.
  Type 'ComponentPublicInstance<{}, {}, {}, {}, { test(): void; }, "test"[], {}, {}, false, ComponentOptionsBase<{}, {}, void, {}, { test(): void; }, ComponentOptionsMixin, ComponentOptionsMixin, "test"[], string, {}>>' is not assignable to type 'ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>'.
    Type 'ComponentPublicInstance<{}, {}, {}, {}, { test(): void; }, "test"[], {}, {}, false, ComponentOptionsBase<{}, {}, void, {}, { test(): void; }, ComponentOptionsMixin, ComponentOptionsMixin, "test"[], string, {}>>' is not assignable to type '{ $: ComponentInternalInstance; $data: {}; $props: {}; $attrs: Record<string, unknown>; $refs: Record<string, unknown>; $slots: Readonly<InternalSlots>; ... 7 more ...; $watch(source: string | Function, cb: Function, options?: WatchOptions<...> | undefined): WatchStopHandle; }'.
      Types of property '$emit' are incompatible.
        Type '(event: "test", ...args: any[]) => void' is not assignable to type '(event: string, ...args: any[]) => void'.
          Types of parameters 'event' and 'event' are incompatible.
            Type 'string' is not assignable to type '"test"'.
    17 |
    18 |        mounted() {
  > 19 |                this.$nextTick(() => {
       |                ^^^^
    20 |
    21 |                });
    22 |        },
@JarvisH
Copy link

JarvisH commented Jun 9, 2021

Any update on when this will be merged?

@github-actions github-actions bot locked and limited conversation to collaborators Oct 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐞 bug Something isn't working scope: types
Projects
None yet
3 participants