-
Notifications
You must be signed in to change notification settings - Fork 82
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
🚧 refactor(types): replace EmitterEventWebhookPayloadMap #441
Conversation
I had originally laid the types out like this (or similar to this), but decided against it in favor of how it is currently as it's easier to predict the behaviour (both in typings and in performance). |
EmitterEventWebhookPayloadMap[keyof EmitterEventWebhookPayloadMap], | ||
{ action: string } | ||
EmitterWebhookEvent["payload"], | ||
{ action: any } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ action: any } | |
{ action: string } |
Nope it'll be fine because that's handled by the types for each payload being a union 🤦 |
src/types.ts
Outdated
[K in Exclude< | ||
typeof emitterEventNames[number], | ||
"error" | ||
>]: K extends `${infer TWebhookEvent}.${infer TAction}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please make this a "type function"? i.e.
type WithAction<...> = K extends ... // etc
src/types.ts
Outdated
|
||
export type EmitterWebhookEventMap = { | ||
[K in keyof EmitterEventPayloadMap]: BaseWebhookEvent<K>; | ||
[K in Exclude< | ||
typeof emitterEventNames[number], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think let's make this a type alias in the generated type:
export type EmitterEventName = typeof emitterEventNames[number];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to get started on a next
branch, which'll likely include this change so going to hold off merging it for now.
Just FYI, as I mentioned in #444: this change causes massive performance problems in the current version of WebStorm - while TypeScript seems to be able to handle it fine, I don't think there's a huge gain to be had that makes it worth putting such a massive blocker on anyone using that IDE. I've submitted an issue on YouTrack and pinged the team, so hopefully it'll get fixed promptly (but even once fixed we'd want to wait for the release, which'd be a few months later). |
I wonder if removing |
That seems to have fixed both this and the performance problems caused by inferring the impact of Currently I'm on the fence about shipping this because of the huge impact if I'm wrong, but def going to keep this patch around to apply it at a later date: patch
In saying that, I think it probably has fixed the issue and I'm just being paranoid 😅 (/cc @anstarovoyt, since it might help you pin down where the performance issue is) |
Awesome, thanks! 👍 |
Could you link please the issue on YouTrack, please? :) 🙏🏽 |
🎉 This issue has been resolved in version 8.0.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Can we eliminate
get-webhook-payload-type-from-event.ts
thanks to #435?EmitterEventWebhookPayloadMap[TName]
withEventPayloadMap[TWebhookEvent] & { action: TAction }
keyof EmitterEventWebhookPayloadMap
withtypeof emitterEventNames[number]