Merge pull request #30226 from Methuselah96/scheduler

[scheduler] Add types for scheduler package
This commit is contained in:
Daniel Rosenwasser
2018-11-04 22:18:41 -08:00
committed by GitHub
4 changed files with 61 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
// Type definitions for scheduler 0.10
// Project: https://reactjs.org/
// Definitions by: Nathan Bierema <https://github.com/Methuselah96>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
export interface Deadline {
timeRemaining(): number;
didTimeout: boolean;
}
export type FrameCallbackType = (deadline: Deadline) => FrameCallbackType | void;
export interface CallbackNode {
callback: FrameCallbackType;
priorityLevel: number;
expirationTime: number;
next: CallbackNode | null;
prev: CallbackNode | null;
}
export const unstable_ImmediatePriority = 1;
export const unstable_UserBlockingPriority = 2;
export const unstable_NormalPriority = 3;
export const unstable_IdlePriority = 4;
export function unstable_runWithPriority<T>(priorityLevel: number, eventHandler: () => T): T | undefined;
export function unstable_scheduleCallback(callback: FrameCallbackType, deprecated_options?: { timeout: number}): CallbackNode;
export function unstable_cancelCallback(callbackNode: CallbackNode): void;
export function unstable_wrapCallback(callback: FrameCallbackType): () => FrameCallbackType | undefined;
export function unstable_getCurrentPriorityLevel(): number;
export function unstable_now(): number;
+8
View File
@@ -0,0 +1,8 @@
import { unstable_scheduleCallback, unstable_cancelCallback, unstable_now } from 'scheduler';
// $ExpectType CallbackNode
const callbackNode = unstable_scheduleCallback(() => {}, { timeout: 100 });
unstable_cancelCallback(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",
"scheduler-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }