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
(WIP, DON'T MERGE) Fix typings in scenes/context.ts #1828
base: v4
Are you sure you want to change the base?
Conversation
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.
lgtm, thanks!
This will need a fix in Wizard Context; but before that, does this fix even work as expected for you? |
I initially wanted to type it as EditI'm happy to add this to the Wizard as well. I didn't do it thus yet, because I haven't been using the Wizard so I didn't run into the same problem. |
@MKRhere Would you want me to apply this fix in the Wizard scene as well? Because I just tried it and I noticed that the wizard scene is set up quite differently from the base scene. And so I would be inclined to refactor it such that it works much more similar to how the base scene works. But I don't know if you guys made it different on purpose. |
We cannot change the behaviour within a major version, and even for v5 there must be justification for the change. Right now, we just want Wizard scene to work along with this change, so there are no type errors. |
Okay, well I can think of a justification? Why would you allow to explicitly define a export default class SceneContextScene<C extends SessionContext<SceneSession<D>>, D extends SceneSessionData = SceneSessionData> {} But not do the same for the Wizard? export default class WizardContextWizard<C extends SessionContext<WizardSession> & {
scene: SceneContextScene<C, WizardSessionData>;
}> {} I can't see any good reason for this disparity. So I'd propose that in v5, export default class WizardContextWizard<
C extends WizardContext<D>,
D extends WizardSessionData = WizardSessionData,
> {} And then also the property And from what I understand, v5 is just around the corner, so we can wait with implementing this PR until v5 for all I care. :-) |
That would be a non-breaking change, because existing code doesn't break if D is not passed. Please make that change and we can land it in v4. |
Even though TypeScript generates errors on some line, which is my I had to use `// @ts-expect-error` a few times, I can assure you that this is more type-correct.
@MKRhere I just pushed a new commit. Now I've really committed to getting it right. So it gets correctly compiled by I am aware that I changed the required generic types of some types. This was the only way to make it work and be type-correct. If that means it can't be accepted for v4, shall I then make a new PR for v5? editWait, I still made a mistake, which was not caught by tsc or the test run, but I caught it by using it in my own code. I'll make a second edit once I've fixed this mistake. edit 2@MKRhere Okay now I fixed all of it. You can try it out for yourself. It's much more type accurate now and it even shows you a warning text when you're giving the wrong type! edit 3Nope, still not all of it is fixed. It's clear that you guys did not anticipate that each scene may want its own well-defined state. So, yeah, don't merge this PR, consider it a Work In Progress Let me know if you see any value in this though? In the end, I'd like to allow the user to define a unique And even, if one does something like: const { enter, leave } = stage
enter<WelcomeSceneState>({ /* whatever fill in the data that the welcome scene expects... */ }) |
Is there a plan to merge this? Current types related to session, scene are broken by my experience. Or is this not related to it? |
I'm sorry, I've been struggling with a depressive episode recently and I haven't been able to get myself to finish this or anything else. If someone else would be willing to take this over then I'd appreciate that. |
I'm sorry to hear that. I hope you will get better soon! If this will not be a burden to you, can you please let me know what's left and push all the progress you have? I would appreciate it. |
@Evertt Please do not stress yourself, take your time to recover. I'll look into this once I have time.
@oitan This PR is only related to |
Eagerly waiting for this to be merged! :) thanks sir |
@SwapnilSoni1999 Hey, well the good news is that my latest depressive episode seems have finally come to an end. The bad news is that my life is now much busier so I still can't promise that I will finish this. But if anyone else is willing to pick up the slack then I very much welcome that. Why not you? 😉 |
Fixes #1827