-
Notifications
You must be signed in to change notification settings - Fork 272
fix: make get() return type adhering to its return type #191
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: make get() return type adhering to its return type #191
Conversation
1764f8b
to
f7af4a3
Compare
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.
Looks good to me, but I think the same should be done to getComponent
no?
src/vueWrapper.ts
Outdated
import { find } from './utils/find' | ||
import { isFunctionalComponent } from './utils' | ||
|
||
type NonexistentDomWrapper<T extends Element> = Omit<DOMWrapper<T>, 'exists'> |
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.
nit: the name NonexistentDomWrapper
sounds a bit weird to me. To my french ear, it sounds like the DomWrapper does not exist 😅 I think we should name it differently, but I don't have a great suggestion...
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 had the same thought... if anything this should ExistsDomWrapper
or NotNullableDomWrapper
.
Since this type is not used much, could we just inline it?
get<K extends keyof HTMLElementTagNameMap>(
selector: K
): ): Omit<<HTMLElementTagNameMap[K]>, 'exists'>
^ Probably wrong but that would be the idea.
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.
Cool! We need to do this for getComponent
too.
src/vueWrapper.ts
Outdated
import { find } from './utils/find' | ||
import { isFunctionalComponent } from './utils' | ||
|
||
type NonexistentDomWrapper<T extends Element> = Omit<DOMWrapper<T>, 'exists'> |
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 had the same thought... if anything this should ExistsDomWrapper
or NotNullableDomWrapper
.
Since this type is not used much, could we just inline it?
get<K extends keyof HTMLElementTagNameMap>(
selector: K
): ): Omit<<HTMLElementTagNameMap[K]>, 'exists'>
^ Probably wrong but that would be the idea.
f7af4a3
to
351157c
Compare
@lmiller1990 @cexbrayat thanks for the suggestions! Making it inline removes the problem regarding the name, which is cool! |
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.
👌
Love it, great job. |
Refers to this
This MR suggests to improve the guideline that
get()
should (and cannot) be used in combination withexists()
by removing it from its return type.The following changes only affect TS users as they will now see an error when using
exists()
on the returnedget()
result (it's assumed that whenget()
cannot find an element, it will just throw). They will need to update the code to usefind()
which is the official recommendation.