TypeScript-DOM-lib-generator icon indicating copy to clipboard operation
TypeScript-DOM-lib-generator copied to clipboard

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

Open ahejlsberg opened this issue 1 year ago • 6 comments

This PR adds /** @deferred */ comments to deferred callback parameters in preparation for https://github.com/microsoft/TypeScript/pull/58729.

ahejlsberg avatar Jul 14 '24 21:07 ahejlsberg

Thanks for the PR!

This section of the codebase is owned by @saschanaz - if they write a comment saying "LGTM" then it will be merged.

github-actions[bot] avatar Jul 14 '24 21:07 github-actions[bot]

You also need to npm run build && npm run baseline-accept.

saschanaz avatar Jul 14 '24 21:07 saschanaz

(Looks good. feel free to merge when the TS PR is ready)

saschanaz avatar Jul 15 '24 07:07 saschanaz

~~One question, why not use deferred modifier when we are using TypeScript here?~~ (Edit: Oh, for backward compat, cool.)

saschanaz avatar Jul 15 '24 07:07 saschanaz

And another question, is it the requirement here for the callback to be called asynchronously? What happens if those callbacks can be called both sync/async?

saschanaz avatar Jul 15 '24 07:07 saschanaz

And another question, is it the requirement here for the callback to be called asynchronously?

The deferred modifier (and the /** @deferred */ JSDoc comment) asserts that the callback is never called synchronously. If a synchronous call is a possibility, then the parameter shouldn't have the modifier.

BTW, I haven't been able to find any authoritative documentation on sync vs. async for the various DOM callbacks, so it could well be that some of the modifiers shouldn't be present.

ahejlsberg avatar Jul 15 '24 15:07 ahejlsberg