Typescript: window.requestIdleCallback

Created on 19 Jan 2018  路  5Comments  路  Source: microsoft/TypeScript

_From @bsvipas on January 19, 2018 7:0_

  • VSCode Version: 1.19.2
  • OS Version: macOS

There's no suggestion for window.requestIdleCallback (rIC) only for window.requestAnimationFrame (rAF).

_Copied from original issue: Microsoft/vscode#41850_

Working as Intended

Most helpful comment

Posting this here for people who want to copy/paste into their projects:

type RequestIdleCallbackHandle = any;
type RequestIdleCallbackOptions = {
  timeout: number;
};
type RequestIdleCallbackDeadline = {
  readonly didTimeout: boolean;
  timeRemaining: (() => number);
};

declare global {
  interface Window {
    requestIdleCallback: ((
      callback: ((deadline: RequestIdleCallbackDeadline) => void),
      opts?: RequestIdleCallbackOptions,
    ) => RequestIdleCallbackHandle);
    cancelIdleCallback: ((handle: RequestIdleCallbackHandle) => void);
  }
}

All 5 comments

We don't include experimental APIs in lib.d.ts

@RyanCavanaugh 馃槩

Too bad.

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

Posting this here for people who want to copy/paste into their projects:

type RequestIdleCallbackHandle = any;
type RequestIdleCallbackOptions = {
  timeout: number;
};
type RequestIdleCallbackDeadline = {
  readonly didTimeout: boolean;
  timeRemaining: (() => number);
};

declare global {
  interface Window {
    requestIdleCallback: ((
      callback: ((deadline: RequestIdleCallbackDeadline) => void),
      opts?: RequestIdleCallbackOptions,
    ) => RequestIdleCallbackHandle);
    cancelIdleCallback: ((handle: RequestIdleCallbackHandle) => void);
  }
}
Was this page helpful?
0 / 5 - 0 ratings