mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Merge pull request #29008 from Methuselah96/schedule
[schedule] Add types
This commit is contained in:
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// Type definitions for schedule 0.5
|
||||
// Project: https://reactjs.org/
|
||||
// Definitions by: Nathan Bierema <https://github.com/Methuselah96>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface Deadline {
|
||||
timeRemaining(): number;
|
||||
didTimeout: boolean;
|
||||
}
|
||||
export type FrameCallbackType = (deadline: Deadline) => void;
|
||||
export interface CallbackNode {
|
||||
callback: FrameCallbackType;
|
||||
timesOutAt: number;
|
||||
next: CallbackNode | null;
|
||||
prev: CallbackNode | null;
|
||||
}
|
||||
|
||||
export function unstable_scheduleWork(callback: FrameCallbackType, options?: { timeout: number }): CallbackNode;
|
||||
export function unstable_cancelScheduledWork(callbackNode: CallbackNode): void;
|
||||
export function unstable_now(): number;
|
||||
@@ -0,0 +1,8 @@
|
||||
import { unstable_scheduleWork, unstable_cancelScheduledWork, unstable_now } from 'schedule';
|
||||
|
||||
// $ExpectType CallbackNode
|
||||
const callbackNode = unstable_scheduleWork(() => 0, { timeout: 100 });
|
||||
unstable_cancelScheduledWork(callbackNode);
|
||||
|
||||
// $ExpectType number
|
||||
unstable_now();
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"schedule-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user