-
Notifications
You must be signed in to change notification settings - Fork 159
Add ability for users to supply generic type #258
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: main
Are you sure you want to change the base?
Add ability for users to supply generic type #258
Conversation
|
Not sure who maintains this project but wanted to get some 👀 on this PR |
|
I'm not sure I'm in favor of this change. This is one of those situations where you're letting the compiler lie to you. I would much rather you add a type guard ( |
Yea I'm glad you called it out. I was following the pattern in Cypress itself but actual type guards would be useful. Let me consider this more. It's also the same way we define it in DOM Testing Library: Adding type guards as far as I can tell will require an API change to all the queries, something like this looks appealing: https://effectivetypescript.com/2020/07/27/safe-queryselector/ Still researching but haven't found many great examples in the wild, maybe because it's sort of straightforward? |
What:
Add ability to supply generic types similar to Cypress's API
Why:
This allows for further narrowing elements returned by queries in tests instead of just
HTMLElementfor every elementHow:
Update types to include generic
<E extends Node = HTMLElement>Ran
npx dslint typeslocally and validated ExpectType tests still passedChecklist: