vue-typed-emit icon indicating copy to clipboard operation
vue-typed-emit copied to clipboard

Vue 3 - Types incompatibility

Open IrvingArmenta opened this issue 3 years ago • 1 comments

Describe the bug

Types incompatibility in vue 3. got this message when applying the example code in SFC - Composition API:

Interface 'ExtendedSetupContext' incorrectly extends interface 'SetupContext<EmitsOptions>'.
  Types of property 'emit' are incompatible.

This is how I setup the code, as the example:

<script lang="ts">
import { defineComponent, ref, PropType, SetupContext } from 'vue';
import { CompositionAPIEmit } from 'vue-typed-emit';

interface Events {
  foo: string;
  bar: [string, number];
  baz: undefined;
}

interface ExtendedSetupContext extends SetupContext {
  emit: CompositionAPIEmit<Events>;
}

// defineComponent and setup(props) call...
</script>

Expected behavior

Emits are properly typed as expected

Versions

Libraries:

 {
    "vue": "^3.0.0",
    "vue-typed-emit": "^1.1.0"
    "typescript": "^4.4.4"
  }

IrvingArmenta avatar Nov 04 '21 04:11 IrvingArmenta

@IrvingArmenta you don't need this library for Vue 3. Vue 3 provides an ability to provide types of emits.

andrewvasilchuk avatar Apr 28 '22 21:04 andrewvasilchuk

This project is not maintained anymore since Vue 3 has introduced a built in support for typing component events.

andrewvasilchuk avatar Jan 08 '23 21:01 andrewvasilchuk