Skip to content
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

ParseSelector return unknown in its return type instead of always using the fallback type when using TS 5.4 #36

Closed
stof opened this issue Mar 13, 2024 · 5 comments · Fixed by #37

Comments

@stof
Copy link

stof commented Mar 13, 2024

See fregante/delegate-it#50 (and fregante/delegate-it#51 which runs the testsuite with typescript 5.4).
See also ed964d1#r139690533 where the discussion started.

To me, the change in the querySelectorAll type in that commit should not exist. It is a workaround for the fact that ParseSelector now returns unknown while it should never do it.
My intuition is that ExpandAnd is the one not properly handling the fallback.

@g-plane
Copy link
Owner

g-plane commented Mar 13, 2024

You can try ParseSelector<':is(a,)'> which is an invalid selector, and it returns Element.

@stof
Copy link
Author

stof commented Mar 13, 2024

The case where this happens is not when having a known selector in ParseSelector but when defining a generic function (i.e. the same case than querySelectorAll in your commit, or in delegate-it)

@stof
Copy link
Author

stof commented Mar 13, 2024

i.e. a case where we don't know whether we will have to use the fallback or a parsed type, but having both branches of the union.

@fregante
Copy link
Contributor

It worked, thank you!

fregante/delegate-it#51

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants