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

webworker: waitUntil should require a Promise #48553

Closed
punkeel opened this issue Apr 4, 2022 · 2 comments · Fixed by microsoft/TypeScript-DOM-lib-generator#1326
Closed

webworker: waitUntil should require a Promise #48553

punkeel opened this issue Apr 4, 2022 · 2 comments · Fixed by microsoft/TypeScript-DOM-lib-generator#1326
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Milestone

Comments

@punkeel
Copy link

punkeel commented Apr 4, 2022

webworker lib Update Request

Missing / Incorrect Definition

Today, ExtendableEvent's waitUntil accepts any. A common mistake is to pass it a function, expecting the engine to call it. It doesn't, and will silently fail.

This is defined here:

waitUntil(f: any): void;

I would argue this needs to be typed as Promise<any> rather than any. This will catch two mistakes:

  • Passing a function, expecting it will be called
  • Passing a value, expecting it won't be called right away (eg: waitUntil(longTask());, with longTask a non-async function).

Documentation Link

https://developer.mozilla.org/en-US/docs/Web/API/ExtendableEvent/waitUntil

Parameters
A Promise.

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this labels Apr 4, 2022
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Apr 4, 2022
@RyanCavanaugh
Copy link
Member

That sounds reasonable

@jakebailey
Copy link
Member

This was fixed in #49596.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants