Skip to content

webworker: waitUntil should require a Promise #48553

Closed
microsoft/TypeScript-DOM-lib-generator
#1326
@punkeel

Description

@punkeel

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions