Merge pull request #29008 from Methuselah96/schedule

[schedule] Add types
This commit is contained in:
Nathan Shively-Sanders
2018-09-19 09:33:46 -07:00
committed by GitHub
4 changed files with 52 additions and 0 deletions
+20
View File
@@ -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;
+8
View File
@@ -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();
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }