Repository navigation
Use aOrB parameter names for union options/primitive parameters - #2577
Samuel Kapust (spkapust) wants to merge 1 commit into
Conversation
|
Thanks for the PR! This section of the codebase is owned by Kagami Sascha Rosylight (@saschanaz) - if they write a comment saying "LGTM" then it will be merged. |
|
@microsoft-github-policy-service agree company="Google" |
|
I'm not sure I like the new names deviating from the spec name. I'd rather switch to multi signature if the parameter name is important. Or maybe we should add comment for parameters instead? Thoughts? Jake Bailey (@jakebailey) |
|
The consensus when we last spoke about it was changing the names instead of multi signature, but happy to hear Jake's latest thoughts as well. |
|
The problem with overloads is that they behave badly when you have unions; you end up being unable to call the overloaded function with one or the other. The only fix is to then introduce more overloads. I honestly don't quite remember where we landed way back then; I had thought you would actually be fixing your tooling rather than the types needing to be updated to make a linter happy? |
|
Hi Jake, |
|
Sorry, I just didn't remember too well, May is decades ago 😄 |
|
No worries! Did you want to proceed with this, go in a different direction, or abandon it? |
Fixes #2470
Several web APIs evolved from accepting a single primitive parameter to accepting a union of that primitive and an options/arg dictionary (e.g.,
boolean | AddEventListenerOptions), replacing the original descriptive parameter name with a genericoptionsorargin WebIDL.Following the naming convention already used in upstream WebIDL for similar APIs (such as
IDBObjectStore.getAll(queryOrOptions)andPerformance.measure(name, startOrMeasureOptions)), this change addsoverrideNamesupport for KDL parameter patches and renames the affected union parameters toaOrBform while preserving each spec'soptionsvs.argprefix:EventTarget.addEventListener(and synthesized event-map overloads):options->optionsOrUseCaptureEventTarget.removeEventListener(and synthesized event-map overloads):options->optionsOrUseCaptureDocument.importNode:options->optionsOrDeepElement.scrollIntoView:arg->argOrAlignToTopHTMLElement.togglePopover:options->optionsOrForcenew SharedWorker:options->optionsOrName