-
Notifications
You must be signed in to change notification settings - Fork 424
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
Consistently use Promise<void> instead of Promise<undefined> #1598
base: main
Are you sure you want to change the base?
Conversation
Thanks for the PR! This section of the codebase is owned by @saschanaz - if they write a comment saying "LGTM" then it will be merged. |
@microsoft-github-policy-service agree company="Deno Land Inc" |
lib.dom.d.ts ubiquitously uses Promise<void> for promises not resolving to undefined. It has done this for a long time. When the generator was written, there were 0 or 1 (I can't quite tell) places where this type of promise occured outside of a function return value. However, Web Streams are now widely supported, and they have properties that are promises that resolve to no value. These are currently typed as Promise<undefined>. This commit changes them to be typed as Promise<void>, to align with the rest of lib.dom.d.ts. There are 5 readonly properties that are impacted by this change.
704e314
to
a6be967
Compare
Can you modify the description as it all says just Promise, I believe you intended to say I'm not sure this is the right direction btw, shouldn't we do the reverse way and do |
@saschanaz indeed, had to escape the < and > chars |
Does this change affect real code btw? Having |
It has a compat issue with lib.deno.web.d.ts, as it uses |
In the absract, switching to I'm not at my desk right now but when I get back I'll try an experiment of manually replacing Promise<void> with Promise<undefined> in the std lib. I see 93 uses. Thinking about it a bit more, most of those 93 uses are the return types of async functions. And I suspect that environments like node and deno have lots more uses like that. So maybe it's better to give these 5 properties worse types for consistency. |
Looking at the results so far, I see three categories of break:
|
This sounds like a bug, both should work same, right? But it does sound like we should compromise here. |
lib.dom.d.ts ubiquitously uses
Promise<void>
for promises not resolvingto undefined. It has done this for a long time.
When the generator was written, there were 0 or 1 (I can't quite tell)
places where this type of promise occured outside of a function return
value. However, Web Streams are now widely supported, and they have
properties that are promises that resolve to no value. These are
currently typed as
Promise<undefined>
. This commit changes them to betyped as
Promise<void>
, to align with the rest of lib.dom.d.ts.There are 5 readonly properties that are impacted by this change.