-
Notifications
You must be signed in to change notification settings - Fork 788
fix(useOverlay): support infering close argument from complex emits #4414
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
base: v3
Are you sure you want to change the base?
fix(useOverlay): support infering close argument from complex emits #4414
Conversation
commit: |
@Teages This is a very strange workaround. Is this necessary to have type inference for lazy loaded components? |
@genu Yes, I think it is pretty useful and lazy compnent is also used in example. The first time I used it I wouldn't have known where I screwed up, if I hadn't looked at the type. The primary goal is to fix the type of lazy loaded components. But the problem will also happens when it have any other emits with have no argument. The recursive solution in the original issue may be more regular, but I think it is too complex for the problem we need to resolve. |
@Teages I took some time to try to replicate the problem, but I haven't been able to identify this edge case. can you share how you are overloading the emits? Do you mean something like this? const emit = defineEmits<{
(event: 'close', result: string): void
(event: 'close', result: number): void
(event: 'close', result: boolean): void
(event: 'close', result: { message: string, code: number }): void
}>() |
@genu Did you look into the playground I provided? Before the PR / After this PR Something like this will break the current type: const emit = defineEmits<{
(event: 'close', result: string): void
(event: 'hydrated'): void // added by lazy component
}>() |
b632a18
to
653146b
Compare
oops I chose the wrong way to sync to the base. nothing edited in the prev force push |
Thanks @Teages That makes better sense now. I've added a comment block to explain a little bit the background behind this and included a link to the original typescript discussion. Feel free to make any more changes. I think its good to go π π |
π Linked issue
Resolves #4413
upstream issue: microsoft/TypeScript#32164
β Type of change
π Description
The PR added the support of infering close argument from complex emits, so that we can get the result type of lazy components.
Verify the changes in TypeScript Playground
The PR supports 16 more overloads, I think that is enough.
π Checklist