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
value of type never can be created using document.all #58502
Comments
That's not how type narrowing works. If the declared type is And since we know that it is both Or are you suggesting that the typing of |
@snarbies |
@snarbies No, I'm saying that the given the information that |
fwiw I doubt TS is going to make a special case in the type checker specifically to account the weirdness of |
Yeah, I don't think this will be fixed. However I think it is nice to at least have an issue for every soundness issue. |
I'm not sure I would even characterize this as a soundness issue. It's closer to magic. There are scenarios that the type system simply can not convey, and this is true of most any type system. Magic, including exotics, by its very nature can and will defy the type system. The only fix here would be to introduce type magic around the |
A better fix would be to remove the type definition for |
|
This issue has been marked as "Won't Fix" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
π Search Terms
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?ts=5.4.5#code/GYVwdgxgLglg9mABMAFANwFyLAUzTgJwEos04YATRAbwChEHEIEBnOAGxwDp24BzFAAMAygAs4IdhTAByKIgBGORAAc4LFjAWcMggDSI0RANy0AvrVrMwLeQA9EAXkQU4EEAFscYKFwCG7OymMMCIKFAAnio4cKEOjgmIMuAUOMAwuBQyRDT0jKh2JuZAA
π» Code
π Actual behavior
The code type checks and
f
is called at runtime even though it has a parameter of typenever
.π Expected behavior
The type of
x
should not be narrowed have typeundefined
whentypeof x === 'undefined'
has been established.Instead it's type should be narrowed to
undefined | HTMLAllCollection
.Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: