-
Notifications
You must be signed in to change notification settings - Fork 264
feat: added typehint to the trigger method #551
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
Conversation
/** | ||
* @deprecated | ||
*/ |
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.
There's probably more I just added the missing properties and saw that it was depricated.
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 like the idea 👍
Do we need tsd tests? This is a pretty nice PR. I'm looking forward to having type hints for events. |
What is there to test? The return value doesn't change depending on the argument. |
I think there are 3 options:
|
I just realized this is the signature in the base wrapper! Maybe we should have different trigger signatures in both wrappers then:
|
That would be great actually (maybe stick an abstract signature into the base wrapper too). As for the vueWrapper I'm not entirely sure how to get the |
I still think t would be better with overloads:
because then TS will pick the first signature when typing For the VueWrapper, I think it's doable to get the emits and fall back to string as well, but I don't know exactly how of the top of my head. It's one of the generic parameters of |
I personally don't mind what we go for, I have never had a problem with the existing typings, but always good to have better IDE hints. This sounds pretty good to me:
Are we planning to make any of these changes here, or shall we merge this as-is, and create another PR with more improvements? |
Please carefully consider the latest commit 9bba382 Currently in summary: |
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.
Thank you for giving this a try. I'm sadly not sure this works in every cases, and not convinced by having to update tests to get the DomWrapper and trigger a DomEvent.
Two possibilities IMO:
- you find a way to handle all emits cases, and remove the need to get the DomWrapper
- or we keep your previous version for now
I have not kept up with this thread - I was away for a few days. VTU v1 needs attention, so I will focus on that for a bit. I will leave the review/decision on this PR to @nandi95 and @cexbrayat 🙏 |
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.
This is starting to look good now 👍
One last thing: as both trigger methods are the same, can't we move it back to the BaseWrapper?
Once that's solved, I think we should merge and cut a release to give it a try.
I could move the one from dom wrapper, but not the vue wrapper one as the base wrapper doesn't have access to |
@nandi95 for the signatures, I agree. but I'm talking about the body of the methods. You can keep the overloaded signatures in both wrappers and simply do |
Ah! didn't think of that 😅 Once this is merged, I'll create an issue for the modifiers |
👍 Did you try pikax suggestion for emits? https://github.com/vuejs/vue-test-utils-next/pull/551/files#r626442106 |
It was resolved, responded now |
Anything else needed here, or we can merge once CI is green? Also no breaking change - right - just types (from what I can see, just checking). |
@lmiller1990 I think @pikax made a suggestion here https://github.com/vuejs/vue-test-utils-next/pull/551/files#r627168878 that @nandi95 may want to try. If it helps, great. If it doesn't then @nandi95 will remove the attempt of having a typed version of trigger in VueWrapper, and I think all the code can go back to the Base Wrapper with the slight improvement to have overloads (one for DomEvent and a fallback to string). TL;DR: we're waiting on @nandi95 update, and there is no breaking change, just a type update 😉 |
Great, thanks for the update @cexbrayat! |
After discussion with @pikax I'm reverting the changes concerning the vue and dom wrapper and keep everthing in the base wrapper for now. I think a discussion or issue can be raised if this comes up again whether should we typehing the event names from the components and its argument My reasoning for this is: |
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.
Awesome, thanks @nandi95 for exploring this 👍
PR is in good shape, I'm going to merge so it can be part of the next RC.
closes #415