Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistently use Promise<void> instead of Promise<undefined> #1598

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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/audioworklet.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ declare var ReadableStreamDefaultReader: {

interface ReadableStreamGenericReader {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/closed) */
readonly closed: Promise<undefined>;
readonly closed: Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/cancel) */
cancel(reason?: any): Promise<void>;
}
Expand Down Expand Up @@ -1121,11 +1121,11 @@ declare var WritableStreamDefaultController: {
*/
interface WritableStreamDefaultWriter<W = any> {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/closed) */
readonly closed: Promise<undefined>;
readonly closed: Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/desiredSize) */
readonly desiredSize: number | null;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/ready) */
readonly ready: Promise<undefined>;
readonly ready: Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/abort) */
abort(reason?: any): Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/close) */
Expand Down
8 changes: 4 additions & 4 deletions baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18564,7 +18564,7 @@ declare var ReadableStreamDefaultReader: {

interface ReadableStreamGenericReader {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/closed) */
readonly closed: Promise<undefined>;
readonly closed: Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/cancel) */
cancel(reason?: any): Promise<void>;
}
Expand Down Expand Up @@ -25448,7 +25448,7 @@ interface WebTransport {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebTransport/incomingUnidirectionalStreams) */
readonly incomingUnidirectionalStreams: ReadableStream;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebTransport/ready) */
readonly ready: Promise<undefined>;
readonly ready: Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebTransport/close) */
close(closeInfo?: WebTransportCloseInfo): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebTransport/createBidirectionalStream) */
Expand Down Expand Up @@ -26055,11 +26055,11 @@ declare var WritableStreamDefaultController: {
*/
interface WritableStreamDefaultWriter<W = any> {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/closed) */
readonly closed: Promise<undefined>;
readonly closed: Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/desiredSize) */
readonly desiredSize: number | null;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/ready) */
readonly ready: Promise<undefined>;
readonly ready: Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/abort) */
abort(reason?: any): Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/close) */
Expand Down
12 changes: 6 additions & 6 deletions baselines/serviceworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ interface ExtendableMessageEventInit extends ExtendableEventInit {

interface FetchEventInit extends ExtendableEventInit {
clientId?: string;
handled?: Promise<undefined>;
handled?: Promise<void>;
preloadResponse?: Promise<any>;
replacesClientId?: string;
request: Request;
Expand Down Expand Up @@ -2475,7 +2475,7 @@ interface FetchEvent extends ExtendableEvent {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/clientId) */
readonly clientId: string;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/handled) */
readonly handled: Promise<undefined>;
readonly handled: Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/preloadResponse) */
readonly preloadResponse: Promise<any>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/request) */
Expand Down Expand Up @@ -4576,7 +4576,7 @@ declare var ReadableStreamDefaultReader: {

interface ReadableStreamGenericReader {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/closed) */
readonly closed: Promise<undefined>;
readonly closed: Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/cancel) */
cancel(reason?: any): Promise<void>;
}
Expand Down Expand Up @@ -7793,7 +7793,7 @@ interface WebTransport {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebTransport/incomingUnidirectionalStreams) */
readonly incomingUnidirectionalStreams: ReadableStream;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebTransport/ready) */
readonly ready: Promise<undefined>;
readonly ready: Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebTransport/close) */
close(closeInfo?: WebTransportCloseInfo): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebTransport/createBidirectionalStream) */
Expand Down Expand Up @@ -8087,11 +8087,11 @@ declare var WritableStreamDefaultController: {
*/
interface WritableStreamDefaultWriter<W = any> {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/closed) */
readonly closed: Promise<undefined>;
readonly closed: Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/desiredSize) */
readonly desiredSize: number | null;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/ready) */
readonly ready: Promise<undefined>;
readonly ready: Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/abort) */
abort(reason?: any): Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/close) */
Expand Down
8 changes: 4 additions & 4 deletions baselines/sharedworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4410,7 +4410,7 @@ declare var ReadableStreamDefaultReader: {

interface ReadableStreamGenericReader {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/closed) */
readonly closed: Promise<undefined>;
readonly closed: Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/cancel) */
cancel(reason?: any): Promise<void>;
}
Expand Down Expand Up @@ -7608,7 +7608,7 @@ interface WebTransport {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebTransport/incomingUnidirectionalStreams) */
readonly incomingUnidirectionalStreams: ReadableStream;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebTransport/ready) */
readonly ready: Promise<undefined>;
readonly ready: Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebTransport/close) */
close(closeInfo?: WebTransportCloseInfo): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebTransport/createBidirectionalStream) */
Expand Down Expand Up @@ -7920,11 +7920,11 @@ declare var WritableStreamDefaultController: {
*/
interface WritableStreamDefaultWriter<W = any> {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/closed) */
readonly closed: Promise<undefined>;
readonly closed: Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/desiredSize) */
readonly desiredSize: number | null;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/ready) */
readonly ready: Promise<undefined>;
readonly ready: Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/abort) */
abort(reason?: any): Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/close) */
Expand Down
12 changes: 6 additions & 6 deletions baselines/webworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ interface ExtendableMessageEventInit extends ExtendableEventInit {

interface FetchEventInit extends ExtendableEventInit {
clientId?: string;
handled?: Promise<undefined>;
handled?: Promise<void>;
preloadResponse?: Promise<any>;
replacesClientId?: string;
request: Request;
Expand Down Expand Up @@ -2675,7 +2675,7 @@ interface FetchEvent extends ExtendableEvent {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/clientId) */
readonly clientId: string;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/handled) */
readonly handled: Promise<undefined>;
readonly handled: Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/preloadResponse) */
readonly preloadResponse: Promise<any>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/request) */
Expand Down Expand Up @@ -4851,7 +4851,7 @@ declare var ReadableStreamDefaultReader: {

interface ReadableStreamGenericReader {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/closed) */
readonly closed: Promise<undefined>;
readonly closed: Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/cancel) */
cancel(reason?: any): Promise<void>;
}
Expand Down Expand Up @@ -8232,7 +8232,7 @@ interface WebTransport {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebTransport/incomingUnidirectionalStreams) */
readonly incomingUnidirectionalStreams: ReadableStream;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebTransport/ready) */
readonly ready: Promise<undefined>;
readonly ready: Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebTransport/close) */
close(closeInfo?: WebTransportCloseInfo): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebTransport/createBidirectionalStream) */
Expand Down Expand Up @@ -8565,11 +8565,11 @@ declare var WritableStreamDefaultController: {
*/
interface WritableStreamDefaultWriter<W = any> {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/closed) */
readonly closed: Promise<undefined>;
readonly closed: Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/desiredSize) */
readonly desiredSize: number | null;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/ready) */
readonly ready: Promise<undefined>;
readonly ready: Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/abort) */
abort(reason?: any): Promise<void>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/close) */
Expand Down
8 changes: 4 additions & 4 deletions src/build/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,10 @@ export function emitWebIdl(
}
if (!obj.type)
throw new Error("Missing 'type' field in " + JSON.stringify(obj));
const type = convertDomTypeToTsTypeWorker(obj);
let type = convertDomTypeToTsTypeWorker(obj);
if (type === "Promise<undefined>") {
type = "Promise<void>";
}
return obj.nullable ? makeNullable(type) : type;
}

Expand All @@ -356,9 +359,6 @@ export function emitWebIdl(
if (type === "undefined") {
return "void";
}
if (type === "Promise<undefined>") {
return "Promise<void>";
}
if (type === "undefined | PromiseLike<undefined>") {
return "void | PromiseLike<void>";
}
Expand Down