How to get the EmitsType of components in TypeScript ? #6116
Answered
by
leopiccionia
zz541843
asked this question in
Help/Questions
|
There is no type prompt for calling component functions through Ref. after looking at the generic types in @vue/runtime-core, how can I extract types similar to objectemitsoptions in definecomponent? |
Answered by
leopiccionia
Jun 18, 2022
Replies: 3 comments 1 reply
|
I tried many times through instancetype, but it didn't work |
0 replies
|
One parameter type in the generic definecomponent is emitsoptions. It can be seen from the source code. The key is how to extract this type |
0 replies
|
Extracting a generic argument in TypeScript typically looks like this (I haven't tested): import type { DefineComponent } from 'vue'
export type ExtractEmits<T> = T extends DefineComponent<any, any, any, any, any, any, any, infer U> ? U : unknownPerhaps #2179 can inspire you, too. |
1 reply
Answer selected by
zz541843
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Extracting a generic argument in TypeScript typically looks like this (I haven't tested):
Perhaps #2179 can inspire you, too.