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

Add /** @deferred */ comments to deferred callback parameters #1757

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
Add /** @deferred */ comments to deferred callback parameters
  • Loading branch information
ahejlsberg committed Jul 14, 2024
commit ea033290ba3a125a0d11aed91dfd8d3aa165dbf7
9 changes: 6 additions & 3 deletions src/build/emitter.ts
Original file line number Diff line number Diff line change
@@ -230,6 +230,8 @@
getParentsWithConstant,
);

const deferredParameterNames = new Set(["handler", "listener", "callback", "successCallback", "errorCallback", "failureCallback"]);

Check failure on line 233 in src/build/emitter.ts

GitHub Actions / test

Replace `"handler",·"listener",·"callback",·"successCallback",·"errorCallback",·"failureCallback"` with `⏎····"handler",⏎····"listener",⏎····"callback",⏎····"successCallback",⏎····"errorCallback",⏎····"failureCallback",⏎··`

Check failure on line 233 in src/build/emitter.ts

GitHub Actions / test

Replace `"handler",·"listener",·"callback",·"successCallback",·"errorCallback",·"failureCallback"` with `⏎····"handler",⏎····"listener",⏎····"callback",⏎····"successCallback",⏎····"errorCallback",⏎····"failureCallback",⏎··`

switch (iterator) {
case "sync":
return emitES6DomIterators();
@@ -685,6 +687,7 @@
const isOptional = !p.variadic && p.optional;
const variadicParams = p.variadic && pType.indexOf("|") !== -1;
return (
(deferredParameterNames.has(p.name) ? "/** @deferred */ ": "") +

Check failure on line 690 in src/build/emitter.ts

GitHub Actions / test

Insert `·`

Check failure on line 690 in src/build/emitter.ts

GitHub Actions / test

Insert `·`
(p.variadic ? "..." : "") +
adjustParamName(p.name) +
(isOptional ? "?: " : ": ") +
@@ -1068,12 +1071,12 @@

if (i.name === "EventSource") {
printer.printLine(
`${fPrefix}${addOrRemove}EventListener(type: string, listener: (this: EventSource, event: MessageEvent) => any, options?: boolean | ${optionsType}): void;`,
`${fPrefix}${addOrRemove}EventListener(type: string, /** @deferred */ listener: (this: EventSource, event: MessageEvent) => any, options?: boolean | ${optionsType}): void;`,
);
}

printer.printLine(
`${fPrefix}${addOrRemove}EventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | ${optionsType}): void;`,
`${fPrefix}${addOrRemove}EventListener(type: string, /** @deferred */ listener: EventListenerOrEventListenerObject, options?: boolean | ${optionsType}): void;`,
);
}
}
@@ -1089,7 +1092,7 @@
printer.printLine(
`${prefix}${addOrRemove}EventListener<K extends keyof ${
iParent.name
}EventMap>(type: K, listener: (this: ${nameWithForwardedTypes(
}EventMap>(type: K, /** @deferred */ listener: (this: ${nameWithForwardedTypes(
i,
)}, ev: ${
iParent.name