Replies: 1 comment
-
you can use const emit: ConstructorOverloads<InstanceType<typeof A>['$emit']> = { ... }
type ConstructorOverloads<T> =
// 4 ...
// 3 ...
// 2
T extends {
(event: infer E1, ...payload: infer P1): void;
(event: infer E2, ...payload: infer P2): void;
} ? (
(E1 extends string ? { [K1 in E1]: (...payload: P1) => void } : {})
& (E2 extends string ? { [K2 in E2]: (...payload: P2) => void } : {})
) :
// 1
T extends {
(event: infer E1, ...payload: infer P1): void;
} ? (
(E1 extends string ? { [K1 in E1]: (...payload: P1) => void } : {})
) :
// 0
unknown; This is TypeScript design limitation, If defineComponent export a property like |
Beta Was this translation helpful? Give feedback.
0 replies
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 find myself using
v-bind
a lot. But one problem I face is typing the value returned insetup
for thev-bind
.E.g.
It would be ideal to have a typescript helper e.g.
BindingOf<Component>
which gives a type containing all the props and event listeners.I am able to get the props of a given component, but struggle to get the
onEvent
listeners.What do you guys think about this suggestion?
Beta Was this translation helpful? Give feedback.
All reactions