Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35284,7 +35284,7 @@ interface Scheduler {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Scheduler/postTask)
*/
postTask(callback: SchedulerPostTaskCallback, options?: SchedulerPostTaskOptions): Promise<any>;
postTask<T = any>(callback: SchedulerPostTaskCallback<T>, options?: SchedulerPostTaskOptions): Promise<T>;
/**
* The **`yield()`** method of the Scheduler interface is used for yielding to the main thread during a task and continuing execution later, with the continuation scheduled as a prioritized task (see the Prioritized Task Scheduling API for more information). This allows long-running work to be broken up so the browser stays responsive.
*
Expand Down Expand Up @@ -43919,8 +43919,8 @@ interface ResizeObserverCallback {
(entries: ResizeObserverEntry[], observer: ResizeObserver): void;
}

interface SchedulerPostTaskCallback {
(): any;
interface SchedulerPostTaskCallback<T = any> {
(): T | PromiseLike<T>;
}

interface TransformerFlushCallback<O> {
Expand Down
6 changes: 3 additions & 3 deletions baselines/serviceworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8558,7 +8558,7 @@ interface Scheduler {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Scheduler/postTask)
*/
postTask(callback: SchedulerPostTaskCallback, options?: SchedulerPostTaskOptions): Promise<any>;
postTask<T = any>(callback: SchedulerPostTaskCallback<T>, options?: SchedulerPostTaskOptions): Promise<T>;
/**
* The **`yield()`** method of the Scheduler interface is used for yielding to the main thread during a task and continuing execution later, with the continuation scheduled as a prioritized task (see the Prioritized Task Scheduling API for more information). This allows long-running work to be broken up so the browser stays responsive.
*
Expand Down Expand Up @@ -13349,8 +13349,8 @@ interface ReportingObserverCallback {
(reports: Report[], observer: ReportingObserver): void;
}

interface SchedulerPostTaskCallback {
(): any;
interface SchedulerPostTaskCallback<T = any> {
(): T | PromiseLike<T>;
}

interface TransformerFlushCallback<O> {
Expand Down
6 changes: 3 additions & 3 deletions baselines/sharedworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8141,7 +8141,7 @@ interface Scheduler {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Scheduler/postTask)
*/
postTask(callback: SchedulerPostTaskCallback, options?: SchedulerPostTaskOptions): Promise<any>;
postTask<T = any>(callback: SchedulerPostTaskCallback<T>, options?: SchedulerPostTaskOptions): Promise<T>;
/**
* The **`yield()`** method of the Scheduler interface is used for yielding to the main thread during a task and continuing execution later, with the continuation scheduled as a prioritized task (see the Prioritized Task Scheduling API for more information). This allows long-running work to be broken up so the browser stays responsive.
*
Expand Down Expand Up @@ -13075,8 +13075,8 @@ interface ReportingObserverCallback {
(reports: Report[], observer: ReportingObserver): void;
}

interface SchedulerPostTaskCallback {
(): any;
interface SchedulerPostTaskCallback<T = any> {
(): T | PromiseLike<T>;
}

interface TransformerFlushCallback<O> {
Expand Down
6 changes: 3 additions & 3 deletions baselines/ts5.5/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35259,7 +35259,7 @@ interface Scheduler {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Scheduler/postTask)
*/
postTask(callback: SchedulerPostTaskCallback, options?: SchedulerPostTaskOptions): Promise<any>;
postTask<T = any>(callback: SchedulerPostTaskCallback<T>, options?: SchedulerPostTaskOptions): Promise<T>;
/**
* The **`yield()`** method of the Scheduler interface is used for yielding to the main thread during a task and continuing execution later, with the continuation scheduled as a prioritized task (see the Prioritized Task Scheduling API for more information). This allows long-running work to be broken up so the browser stays responsive.
*
Expand Down Expand Up @@ -43893,8 +43893,8 @@ interface ResizeObserverCallback {
(entries: ResizeObserverEntry[], observer: ResizeObserver): void;
}

interface SchedulerPostTaskCallback {
(): any;
interface SchedulerPostTaskCallback<T = any> {
(): T | PromiseLike<T>;
}

interface TransformerFlushCallback<O> {
Expand Down
6 changes: 3 additions & 3 deletions baselines/ts5.5/serviceworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8555,7 +8555,7 @@ interface Scheduler {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Scheduler/postTask)
*/
postTask(callback: SchedulerPostTaskCallback, options?: SchedulerPostTaskOptions): Promise<any>;
postTask<T = any>(callback: SchedulerPostTaskCallback<T>, options?: SchedulerPostTaskOptions): Promise<T>;
/**
* The **`yield()`** method of the Scheduler interface is used for yielding to the main thread during a task and continuing execution later, with the continuation scheduled as a prioritized task (see the Prioritized Task Scheduling API for more information). This allows long-running work to be broken up so the browser stays responsive.
*
Expand Down Expand Up @@ -13346,8 +13346,8 @@ interface ReportingObserverCallback {
(reports: Report[], observer: ReportingObserver): void;
}

interface SchedulerPostTaskCallback {
(): any;
interface SchedulerPostTaskCallback<T = any> {
(): T | PromiseLike<T>;
}

interface TransformerFlushCallback<O> {
Expand Down
6 changes: 3 additions & 3 deletions baselines/ts5.5/sharedworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8138,7 +8138,7 @@ interface Scheduler {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Scheduler/postTask)
*/
postTask(callback: SchedulerPostTaskCallback, options?: SchedulerPostTaskOptions): Promise<any>;
postTask<T = any>(callback: SchedulerPostTaskCallback<T>, options?: SchedulerPostTaskOptions): Promise<T>;
/**
* The **`yield()`** method of the Scheduler interface is used for yielding to the main thread during a task and continuing execution later, with the continuation scheduled as a prioritized task (see the Prioritized Task Scheduling API for more information). This allows long-running work to be broken up so the browser stays responsive.
*
Expand Down Expand Up @@ -13072,8 +13072,8 @@ interface ReportingObserverCallback {
(reports: Report[], observer: ReportingObserver): void;
}

interface SchedulerPostTaskCallback {
(): any;
interface SchedulerPostTaskCallback<T = any> {
(): T | PromiseLike<T>;
}

interface TransformerFlushCallback<O> {
Expand Down
6 changes: 3 additions & 3 deletions baselines/ts5.5/webworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9706,7 +9706,7 @@ interface Scheduler {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Scheduler/postTask)
*/
postTask(callback: SchedulerPostTaskCallback, options?: SchedulerPostTaskOptions): Promise<any>;
postTask<T = any>(callback: SchedulerPostTaskCallback<T>, options?: SchedulerPostTaskOptions): Promise<T>;
/**
* The **`yield()`** method of the Scheduler interface is used for yielding to the main thread during a task and continuing execution later, with the continuation scheduled as a prioritized task (see the Prioritized Task Scheduling API for more information). This allows long-running work to be broken up so the browser stays responsive.
*
Expand Down Expand Up @@ -15172,8 +15172,8 @@ interface ReportingObserverCallback {
(reports: Report[], observer: ReportingObserver): void;
}

interface SchedulerPostTaskCallback {
(): any;
interface SchedulerPostTaskCallback<T = any> {
(): T | PromiseLike<T>;
}

interface TransformerFlushCallback<O> {
Expand Down
6 changes: 3 additions & 3 deletions baselines/ts5.6/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35281,7 +35281,7 @@ interface Scheduler {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Scheduler/postTask)
*/
postTask(callback: SchedulerPostTaskCallback, options?: SchedulerPostTaskOptions): Promise<any>;
postTask<T = any>(callback: SchedulerPostTaskCallback<T>, options?: SchedulerPostTaskOptions): Promise<T>;
/**
* The **`yield()`** method of the Scheduler interface is used for yielding to the main thread during a task and continuing execution later, with the continuation scheduled as a prioritized task (see the Prioritized Task Scheduling API for more information). This allows long-running work to be broken up so the browser stays responsive.
*
Expand Down Expand Up @@ -43916,8 +43916,8 @@ interface ResizeObserverCallback {
(entries: ResizeObserverEntry[], observer: ResizeObserver): void;
}

interface SchedulerPostTaskCallback {
(): any;
interface SchedulerPostTaskCallback<T = any> {
(): T | PromiseLike<T>;
}

interface TransformerFlushCallback<O> {
Expand Down
6 changes: 3 additions & 3 deletions baselines/ts5.6/serviceworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8555,7 +8555,7 @@ interface Scheduler {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Scheduler/postTask)
*/
postTask(callback: SchedulerPostTaskCallback, options?: SchedulerPostTaskOptions): Promise<any>;
postTask<T = any>(callback: SchedulerPostTaskCallback<T>, options?: SchedulerPostTaskOptions): Promise<T>;
/**
* The **`yield()`** method of the Scheduler interface is used for yielding to the main thread during a task and continuing execution later, with the continuation scheduled as a prioritized task (see the Prioritized Task Scheduling API for more information). This allows long-running work to be broken up so the browser stays responsive.
*
Expand Down Expand Up @@ -13346,8 +13346,8 @@ interface ReportingObserverCallback {
(reports: Report[], observer: ReportingObserver): void;
}

interface SchedulerPostTaskCallback {
(): any;
interface SchedulerPostTaskCallback<T = any> {
(): T | PromiseLike<T>;
}

interface TransformerFlushCallback<O> {
Expand Down
6 changes: 3 additions & 3 deletions baselines/ts5.6/sharedworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8138,7 +8138,7 @@ interface Scheduler {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Scheduler/postTask)
*/
postTask(callback: SchedulerPostTaskCallback, options?: SchedulerPostTaskOptions): Promise<any>;
postTask<T = any>(callback: SchedulerPostTaskCallback<T>, options?: SchedulerPostTaskOptions): Promise<T>;
/**
* The **`yield()`** method of the Scheduler interface is used for yielding to the main thread during a task and continuing execution later, with the continuation scheduled as a prioritized task (see the Prioritized Task Scheduling API for more information). This allows long-running work to be broken up so the browser stays responsive.
*
Expand Down Expand Up @@ -13072,8 +13072,8 @@ interface ReportingObserverCallback {
(reports: Report[], observer: ReportingObserver): void;
}

interface SchedulerPostTaskCallback {
(): any;
interface SchedulerPostTaskCallback<T = any> {
(): T | PromiseLike<T>;
}

interface TransformerFlushCallback<O> {
Expand Down
6 changes: 3 additions & 3 deletions baselines/ts5.6/webworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9706,7 +9706,7 @@ interface Scheduler {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Scheduler/postTask)
*/
postTask(callback: SchedulerPostTaskCallback, options?: SchedulerPostTaskOptions): Promise<any>;
postTask<T = any>(callback: SchedulerPostTaskCallback<T>, options?: SchedulerPostTaskOptions): Promise<T>;
/**
* The **`yield()`** method of the Scheduler interface is used for yielding to the main thread during a task and continuing execution later, with the continuation scheduled as a prioritized task (see the Prioritized Task Scheduling API for more information). This allows long-running work to be broken up so the browser stays responsive.
*
Expand Down Expand Up @@ -15172,8 +15172,8 @@ interface ReportingObserverCallback {
(reports: Report[], observer: ReportingObserver): void;
}

interface SchedulerPostTaskCallback {
(): any;
interface SchedulerPostTaskCallback<T = any> {
(): T | PromiseLike<T>;
}

interface TransformerFlushCallback<O> {
Expand Down
6 changes: 3 additions & 3 deletions baselines/ts5.9/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35281,7 +35281,7 @@ interface Scheduler {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Scheduler/postTask)
*/
postTask(callback: SchedulerPostTaskCallback, options?: SchedulerPostTaskOptions): Promise<any>;
postTask<T = any>(callback: SchedulerPostTaskCallback<T>, options?: SchedulerPostTaskOptions): Promise<T>;
/**
* The **`yield()`** method of the Scheduler interface is used for yielding to the main thread during a task and continuing execution later, with the continuation scheduled as a prioritized task (see the Prioritized Task Scheduling API for more information). This allows long-running work to be broken up so the browser stays responsive.
*
Expand Down Expand Up @@ -43916,8 +43916,8 @@ interface ResizeObserverCallback {
(entries: ResizeObserverEntry[], observer: ResizeObserver): void;
}

interface SchedulerPostTaskCallback {
(): any;
interface SchedulerPostTaskCallback<T = any> {
(): T | PromiseLike<T>;
}

interface TransformerFlushCallback<O> {
Expand Down
6 changes: 3 additions & 3 deletions baselines/ts5.9/serviceworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8555,7 +8555,7 @@ interface Scheduler {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Scheduler/postTask)
*/
postTask(callback: SchedulerPostTaskCallback, options?: SchedulerPostTaskOptions): Promise<any>;
postTask<T = any>(callback: SchedulerPostTaskCallback<T>, options?: SchedulerPostTaskOptions): Promise<T>;
/**
* The **`yield()`** method of the Scheduler interface is used for yielding to the main thread during a task and continuing execution later, with the continuation scheduled as a prioritized task (see the Prioritized Task Scheduling API for more information). This allows long-running work to be broken up so the browser stays responsive.
*
Expand Down Expand Up @@ -13346,8 +13346,8 @@ interface ReportingObserverCallback {
(reports: Report[], observer: ReportingObserver): void;
}

interface SchedulerPostTaskCallback {
(): any;
interface SchedulerPostTaskCallback<T = any> {
(): T | PromiseLike<T>;
}

interface TransformerFlushCallback<O> {
Expand Down
6 changes: 3 additions & 3 deletions baselines/ts5.9/sharedworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8138,7 +8138,7 @@ interface Scheduler {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Scheduler/postTask)
*/
postTask(callback: SchedulerPostTaskCallback, options?: SchedulerPostTaskOptions): Promise<any>;
postTask<T = any>(callback: SchedulerPostTaskCallback<T>, options?: SchedulerPostTaskOptions): Promise<T>;
/**
* The **`yield()`** method of the Scheduler interface is used for yielding to the main thread during a task and continuing execution later, with the continuation scheduled as a prioritized task (see the Prioritized Task Scheduling API for more information). This allows long-running work to be broken up so the browser stays responsive.
*
Expand Down Expand Up @@ -13072,8 +13072,8 @@ interface ReportingObserverCallback {
(reports: Report[], observer: ReportingObserver): void;
}

interface SchedulerPostTaskCallback {
(): any;
interface SchedulerPostTaskCallback<T = any> {
(): T | PromiseLike<T>;
}

interface TransformerFlushCallback<O> {
Expand Down
6 changes: 3 additions & 3 deletions baselines/ts5.9/webworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9706,7 +9706,7 @@ interface Scheduler {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Scheduler/postTask)
*/
postTask(callback: SchedulerPostTaskCallback, options?: SchedulerPostTaskOptions): Promise<any>;
postTask<T = any>(callback: SchedulerPostTaskCallback<T>, options?: SchedulerPostTaskOptions): Promise<T>;
/**
* The **`yield()`** method of the Scheduler interface is used for yielding to the main thread during a task and continuing execution later, with the continuation scheduled as a prioritized task (see the Prioritized Task Scheduling API for more information). This allows long-running work to be broken up so the browser stays responsive.
*
Expand Down Expand Up @@ -15172,8 +15172,8 @@ interface ReportingObserverCallback {
(reports: Report[], observer: ReportingObserver): void;
}

interface SchedulerPostTaskCallback {
(): any;
interface SchedulerPostTaskCallback<T = any> {
(): T | PromiseLike<T>;
}

interface TransformerFlushCallback<O> {
Expand Down
6 changes: 3 additions & 3 deletions baselines/webworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9709,7 +9709,7 @@ interface Scheduler {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Scheduler/postTask)
*/
postTask(callback: SchedulerPostTaskCallback, options?: SchedulerPostTaskOptions): Promise<any>;
postTask<T = any>(callback: SchedulerPostTaskCallback<T>, options?: SchedulerPostTaskOptions): Promise<T>;
/**
* The **`yield()`** method of the Scheduler interface is used for yielding to the main thread during a task and continuing execution later, with the continuation scheduled as a prioritized task (see the Prioritized Task Scheduling API for more information). This allows long-running work to be broken up so the browser stays responsive.
*
Expand Down Expand Up @@ -15175,8 +15175,8 @@ interface ReportingObserverCallback {
(reports: Report[], observer: ReportingObserver): void;
}

interface SchedulerPostTaskCallback {
(): any;
interface SchedulerPostTaskCallback<T = any> {
(): T | PromiseLike<T>;
}

interface TransformerFlushCallback<O> {
Expand Down
38 changes: 38 additions & 0 deletions inputfiles/overridingTypes.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,19 @@
}
}
},
"SchedulerPostTaskCallback": {
"typeParameters": [
{
"name": "T",
"default": "any"
}
],
"signature": {
"0": {
"overrideType": "T | PromiseLike<T>"
}
}
},
"UnderlyingSourceStartCallback": {
"typeParameters": [
{
Expand Down Expand Up @@ -1891,6 +1904,31 @@
]
}
},
"Scheduler": {
"methods": {
"method": {
"postTask": {
"signature": {
"0": {
"typeParameters": [
{
"name": "T",
"default": "any"
}
],
"param": [
{
"name": "callback",
"overrideType": "SchedulerPostTaskCallback<T>"
}
],
"overrideType": "Promise<T>"
}
}
}
}
}
},
"MessagePort": {
"methods": {
"method": {
Expand Down
26 changes: 26 additions & 0 deletions unittests/files/schedulerPostTask.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function assertType<T>(_x: T) {}

type Equals<A, B> =
(<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2
? true
: false;
declare function assertExact<T extends true>(): void;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are variations of this already in other tests, we should have a shared definition...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right about the shared definition. I'd be happy to follow up with a PR going that way, are you OK with that?


async function testSchedulerPostTask() {
const num = await scheduler.postTask(() => 42);
assertExact<Equals<typeof num, number>>();

const str = await scheduler.postTask(async () => "done", {
priority: "background",
});
assertExact<Equals<typeof str, string>>();

const nothing = await scheduler.postTask(() => {});
assertExact<Equals<typeof nothing, void>>();

// @ts-expect-error The result is a number, not a string.
assertType<string>(await scheduler.postTask(() => 42));

// An explicit `any` type argument keeps the previous behavior.
assertType<Promise<any>>(scheduler.postTask<any>(() => 1));
}
Loading