edge-developer icon indicating copy to clipboard operation
edge-developer copied to clipboard

Some Ambiguity on WebView2 HostObjectAsyncProxyBase Documentation

Open gilmorem560 opened this issue 1 year ago • 4 comments

Hello, I've been reviewing the WebView2 JavaScript interface documentation as I prepare a set of TypeScript interfaces for a project I'm working on and I noticed a few problems with the HostObjectAsyncProxyBase page:

  • getLocalProperty has a return type of "any" in the code quote but the Returns section, despite also listing any, then describes "A promise representing the value of the property."
  • setLocalProperty suffers from the same, listing an "any" type in the code quote and at the top of Returns, but then describes the return as a Promise.
  • Also on setLocalProperty, the "propertyName" argument is described as "Name of the property to get the value of." rather than "Name of the property of which to set the value."

The last one is minor but the first two have me wondering whether I should stick "any" or "Promise" on my interfaces.

I'm going through and modelling the whole JavaScript interface so if I find any other similar problems I'll add them to this ticket.


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

AB#45821088

gilmorem560 avatar Aug 03 '23 01:08 gilmorem560

Alright a couple more:

  • The above issue with setLocalProperty "propertyName" description describing a get also applies to the page for HostObjectSyncProxy
  • Additionally, on both HostObjectAsyncProxyBase and HostObjectSyncProxy, the argument propertyValue for setHostProperty is described as "Value to set the property." whereas the corresponding argument to setLocalProperty is described as "Value to set the property to."

So just typographical errors, the only one leading to an actual conflict is the question of whether the asynchronous proxy methods which operate on the local object are also async or not (given they're local objects, one would assume not, but the Returns section does mention "promise" so I want to be sure.)

gilmorem560 avatar Aug 03 '23 01:08 gilmorem560

Oh, that's interesting. Thank you for filing. I agree that these descriptions are confusing. Let me make sure that this issue is tracked on our backlog, and we'll get to it as soon as possible.

captainbrosset avatar Aug 03 '23 08:08 captainbrosset

Thanks for reporting these issues! Seems like we have several "copy/paste" style errors =)

getLocalProperty has a return type of "any" in the code quote but the Returns section, despite also listing any, then describes "A promise representing the value of the property."

Yes like you say, that is not a Promise. It should be any.

setLocalProperty suffers from the same, listing an "any" type in the code quote and at the top of Returns, but then describes the return as a Promise.

Yes same issue. It should be any not Promise.

Also on setLocalProperty, the "propertyName" argument is described as "Name of the property to get the value of." rather than "Name of the property of which to set the value."

Good point - will fix thanks

The above issue with setLocalProperty "propertyName" description describing a get also applies to the page for HostObjectSyncProxy

We'll fix this as well.

Additionally, on both HostObjectAsyncProxyBase and HostObjectSyncProxy, the argument propertyValue for setHostProperty is described as "Value to set the property." whereas the corresponding argument to setLocalProperty is described as "Value to set the property to."

Yes we'll fix that thanks.

david-risney avatar Sep 07 '23 17:09 david-risney

Much appreciated! Hope I'm not being to nitpicky by the way, the types thing makes sense in context, but I could also see someone trying to wrap those in promises anyway just to be consistent. The joys of architecting an interface am I right?

gilmorem560 avatar Sep 14 '23 00:09 gilmorem560

PR 3243 is live (Fix typos in JS AddHostObjectAsyncProxyBase & AddHostObjectSyncProxy). https://learn.microsoft.com/microsoft-edge/webview2/reference/javascript/hostobjectasyncproxybase https://learn.microsoft.com/microsoft-edge/webview2/reference/javascript/hostobjectsyncproxy

mikehoffms avatar Aug 07 '24 18:08 mikehoffms