-
Notifications
You must be signed in to change notification settings - Fork 2
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
fix: bug in typings after recent PR #95
Conversation
The problem is that there are other valid event types than the ones currently typed, and they are unknown. Neither solution is great, and I'm now sure which one is worst. If only TypeScript had negated types. We could examine if the new const in typescript 5 would allow anything useful here. But if we're stuck with the imperfect way it currently works I'd love arguments on this solution rather than type-casting. And if we go with this we should probably add some comments about how any custom events would have to have their own interface created for them when used. Does @jimmycallin have any thoughts? I know you've struggled with the lack of negated types before. |
I think the way forward is to define all of the event types to be honest. And I don't think the current state of things in this PR is very bad. I think the alternative is worse. |
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 inclined to agree that unknown types breaking the type discrimination might be worse. I have some ideas on how to make it more easily extendable and versatile, but that would have to wait until the event typing overhaul I mentioned in the previous PR.
Added a comment suggestion for informing about the incompleteness of the type definitions.
Co-authored-by: Lars Johansson <[email protected]>
That's a great idea. How many event types are there in Ftrack, and does it take too long to make them all? Can they somehow be auto-generated? |
The event hub forwards any event sent to it, with arbitrary topics and arbitrary data. They have been added when they were needed from whatever part of the stack needed them. That's why it takes some research to find them all, document what data they contain, and whether they are public events or just events we use internally. So I'm not sure how many there are that are missing, but from the previous investigation I started there's about a handful. |
I am an idiot. I think I forgot to bump the version in package.json. So it was not released. |
We don't manually bump, that is done through the release scripts. I'll check what went wrong. edit: I accidentally named the version |
Thanks a lot! |
Co-authored-by: Lars Johansson <[email protected]>
Changes
I removed the Unknown event type. It ruins the type discrimination it seems. Not sure how this was not caught by me earlier. Apologies. Didn't discover this until I had to consume the event myself.
Test
Test that the types are still OK.