mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 23:37:04 +00:00
Add unstable_next() to the React scheduler (#38974)
* Add unstable_next to the React scheduler * Apply suggestions from code review Co-Authored-By: Nathan Bierema <nbierema@gmail.com> * Update tests with aditional undefined result type * No undefined because errors aren't caught and bubble up
This commit is contained in:
committed by
Andrew Branch
co-authored by
Nathan Bierema
parent
a5b172f575
commit
b5d9f57930
Vendored
+3
-2
@@ -19,10 +19,11 @@ export const unstable_UserBlockingPriority = 2;
|
||||
export const unstable_NormalPriority = 3;
|
||||
export const unstable_IdlePriority = 5;
|
||||
export const unstable_LowPriority = 4;
|
||||
export function unstable_runWithPriority<T>(priorityLevel: number, eventHandler: () => T): T | undefined;
|
||||
export function unstable_runWithPriority<T>(priorityLevel: number, eventHandler: () => T): T;
|
||||
export function unstable_scheduleCallback(priorityLevel: number, callback: FrameCallbackType, options?: { delay?: number, timeout?: number}): CallbackNode;
|
||||
export function unstable_next<T>(eventHandler: () => T): T;
|
||||
export function unstable_cancelCallback(callbackNode: CallbackNode): void;
|
||||
export function unstable_wrapCallback(callback: FrameCallbackType): () => FrameCallbackType | undefined;
|
||||
export function unstable_wrapCallback(callback: FrameCallbackType): () => FrameCallbackType;
|
||||
export function unstable_getCurrentPriorityLevel(): number;
|
||||
export function unstable_shouldYield(): boolean;
|
||||
export function unstable_continueExecution(): void;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { unstable_scheduleCallback, unstable_cancelCallback, unstable_now, unstable_NormalPriority } from 'scheduler';
|
||||
import { unstable_scheduleCallback, unstable_cancelCallback, unstable_now, unstable_NormalPriority, unstable_next } from 'scheduler';
|
||||
|
||||
// $ExpectType CallbackNode
|
||||
const callbackNode = unstable_scheduleCallback(unstable_NormalPriority, () => {}, { timeout: 100 });
|
||||
@@ -7,3 +7,8 @@ unstable_scheduleCallback(unstable_NormalPriority, () => {}, { delay: 100 });
|
||||
|
||||
// $ExpectType number
|
||||
unstable_now();
|
||||
|
||||
// $ExpectType number
|
||||
const nextNumberResult = unstable_next(() => 42);
|
||||
// $ExpectType string
|
||||
const nextStringResult = unstable_next(() => 'Hello');
|
||||
|
||||
Reference in New Issue
Block a user