Skip to content

Conversation

@Bashamega
Copy link
Contributor

fixes #2197

Related #2053

@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2025

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.

@@ -0,0 +1,9 @@
interface Element {
method scroll overrideType=void
Copy link
Contributor

Choose a reason for hiding this comment

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

type=undefined should do it as an IDL type

Copy link
Contributor

Choose a reason for hiding this comment

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

As you see in #2196 it's more than just Element but also Window.

@saschanaz
Copy link
Contributor

Title should be "override scroll methods to return void until browser implementation changes" or something.

method[methodName] = handleMethod(child);
const m = handleMethod(child);
if (method[methodName]) {
// ts: The goal here is to merge multiple method signatures together for methods with the same name.
Copy link
Contributor

@saschanaz saschanaz Nov 5, 2025

Choose a reason for hiding this comment

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

we already have a better solution in another PR, no? This is weird.

I take this back and added another comment below.

| DeepPartial<Signature>[]
| Record<string, DeepPartial<Signature>> = child.properties?.overrideType
? {
"0": {
Copy link
Contributor

@saschanaz saschanaz Nov 5, 2025

Choose a reason for hiding this comment

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

This certainly is the key but I don't think we should do it this way, What if we only want to override the second signature but leave the first one as-is?

What about something like:

method name signatureIndex=0 type=undefined

And then we return object as signature list instead of an array if signatureIndex exists?

@Bashamega Bashamega changed the title Fix: Async scroll...() methods are non-async in fact override scroll methods to return void until browser implementation changes Nov 5, 2025
@Bashamega
Copy link
Contributor Author

I have updated it @saschanaz

I couldn't update window, because it gave me this error
file:///home/adam/os/TypeScript-DOM-lib-generator/lib/build/emitter.js:766
method.signature.forEach((sig) => emitSignature(sig, prefix, name, printLine, shouldResolvePromise));
^

TypeError: method.signature.forEach is not a function
at emitSignatures (file:///home/adam/os/TypeScript-DOM-lib-generator/lib/build/emitter.js:766:30)
at emitMethod (file:///home/adam/os/TypeScript-DOM-lib-generator/lib/build/emitter.js:751:9)
at file:///home/adam/os/TypeScript-DOM-lib-generator/lib/build/emitter.js:790:33
at Array.forEach ()
at emitMethods (file:///home/adam/os/TypeScript-DOM-lib-generator/lib/build/emitter.js:790:18)
at emitMembers (file:///home/adam/os/TypeScript-DOM-lib-generator/lib/build/emitter.js:830:9)
at emitInterface (file:///home/adam/os/TypeScript-DOM-lib-generator/lib/build/emitter.js:1063:9)
at emitNonCallbackInterfaces (file:///home/adam/os/TypeScript-DOM-lib-generator/lib/build/emitter.js:1092:17)
at emit (file:///home/adam/os/TypeScript-DOM-lib-generator/lib/build/emitter.js:1184:9)
at emitWebIdl (file:///home/adam/os/TypeScript-DOM-lib-generator/lib/build/emitter.js:156:21)

Copy link
Contributor

@saschanaz saschanaz left a comment

Choose a reason for hiding this comment

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

Looks much better, thanks.

: T;

interface Method extends Omit<originalMethod, "signature"> {
signature: DeepPartial<Signature>[] | Record<string, DeepPartial<Signature>>;
Copy link
Contributor

Choose a reason for hiding this comment

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

It's more like Record<number, ...>, and maybe name the interface something like OverridableMethod, so that we don't have to rename the pure Method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

? handleTyped(typeNode)
: {
type: string(child.properties?.returns),
subtype: undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

why subtype?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With out it it will become undefind<undefind>

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, fair. if one needs subtype they should use nested types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay

};

let signature: Method["signature"];
const signatureIndex = child.properties?.signatureIndex;
Copy link
Contributor

Choose a reason for hiding this comment

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

time to add number()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why? Sometimes it is undefined

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, fair.

@saschanaz
Copy link
Contributor

I couldn't update window, because it gave me this error file:///home/adam/os/TypeScript-DOM-lib-generator/lib/build/emitter.js:766 method.signature.forEach((sig) => emitSignature(sig, prefix, name, printLine, shouldResolvePromise)); ^

Meaning you may have touched a non-existent method. signatureIndex would work only for an existing method. Note that not all Element methods exist in Window and try again based on that?

@saschanaz
Copy link
Contributor

Much more concise than the initial PR. Thanks, LGTM

@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2025

There was an issue merging, maybe try again saschanaz. Details

@Bashamega
Copy link
Contributor Author

I am still working on the rest

@saschanaz
Copy link
Contributor

Oh right, the window methods.

@Bashamega
Copy link
Contributor Author

Done @saschanaz

method scrollBy returns=void signatureIndex=1
method scrollTo returns=void signatureIndex=0
method scrollTo returns=void signatureIndex=1
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Lastly let's put this in cssom-view.kdl

Copy link
Contributor

Choose a reason for hiding this comment

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

With some comments like "No implementation of Promise return values as of 2025-11"

@Bashamega
Copy link
Contributor Author

I have updated it @saschanaz

@saschanaz
Copy link
Contributor

LGTM2

@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2025

There was an issue merging, maybe try again saschanaz. Details

@Bashamega
Copy link
Contributor Author

Can you review this @jakebailey
Thank you 😊

Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

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

I feel like this is futile given 6.0 isn't even out and neither is the change, but a pure revert for now I guess is fine. Just seems silly to argue that this matters.

@turansky
Copy link

turansky commented Nov 6, 2025

Can we use Promise<void> | void as return type?
It's expected baseline for nearest 2 years.

@saschanaz
Copy link
Contributor

saschanaz commented Nov 6, 2025

We will migrate to Promise<void> if at least two browser engines are ready.

@saschanaz
Copy link
Contributor

LGTM

@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

There was an issue merging, maybe try again saschanaz. Details

@jakebailey jakebailey merged commit 3ebbf4f into microsoft:main Nov 6, 2025
7 checks passed
@Bashamega Bashamega deleted the remove-promise branch November 6, 2025 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Web API type definition issue] Async scroll...() methods are non-async in fact

4 participants