mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 21:10:23 +00:00
Added window interface and tests to requestidlecallback: Part 2 (#38124)
* added tests and updated requestidlecallback type * added tests and updated requestidlecallback type * - corrected arguments according to feedback.
This commit is contained in:
committed by
Ben Lichtman
parent
6d08375709
commit
1e76cc036f
Vendored
+6
-1
@@ -1,6 +1,6 @@
|
||||
// Type definitions for requestidlecallback 0.1
|
||||
// Project: https://w3c.github.io/requestidlecallback/, https://github.com/afarkas/requestidlecallback
|
||||
// Definitions by: 贺师俊 <https://github.com/hax>
|
||||
// Definitions by: 贺师俊 <https://github.com/hax>, Vladimir Grenaderov <https://github.com/VladimirGrenaderov>, Max Boguslavskiy <https://github.com/maxbogus>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export function requestIdleCallback(callback: IdleRequestCallback, options?: IdleRequestOptions): IdleCallbackHandle;
|
||||
@@ -19,3 +19,8 @@ export interface IdleDeadline {
|
||||
export interface IdleRequestOptions {
|
||||
timeout: number;
|
||||
}
|
||||
|
||||
export interface Window {
|
||||
requestIdleCallback(callback: IdleRequestCallback, options?: IdleRequestOptions): IdleCallbackHandle;
|
||||
cancelIdleCallback(handle: number): void;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import {
|
||||
requestIdleCallback,
|
||||
cancelIdleCallback,
|
||||
IdleRequestOptions,
|
||||
IdleCallbackHandle,
|
||||
} from 'requestidlecallback';
|
||||
|
||||
// Test requestIdleCallback with default param
|
||||
requestIdleCallback(() => '1');
|
||||
|
||||
// Test requestIdleCallback with default param and optional param
|
||||
const option: IdleRequestOptions = { timeout: 2000 };
|
||||
requestIdleCallback(() => '2', option);
|
||||
|
||||
// Test cancelIdleCallback with default param
|
||||
const handle: IdleCallbackHandle = 1;
|
||||
cancelIdleCallback(handle);
|
||||
@@ -17,6 +17,7 @@
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts"
|
||||
"index.d.ts",
|
||||
"requestidlecallback-tests.ts"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user