overload for emittable events #809
michaelcozzolino
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have the following component
The goal of this component is to have a stringable number and allow a nullable value in case we have 0 when the
null
modifier is specified. The v-model with the current vuejs features emits an event with the following signature(e: 'update:modelValue', modelValue: string | null): void;
but it does not take into account the modifier, so I would like to have different emit function signature depending on the modifier whenever it is required. It means having sort of overloads for the defineEmits, that in case of the v-model could be specified in the defineModel template or manually in the emits such as
UPDATE:
actually it seems, this is possible by using a generic component
<script setup lang="ts" generic="T extends string | (string | null)">
but I'm not sure it is the right way to do it
Beta Was this translation helpful? Give feedback.
All reactions