Lusito / webextension-polyfill-ts

This is a TypeScript ready "wrapper" for the WebExtension browser API Polyfill by Mozilla
zlib License
392 stars 23 forks source link

storage.StorageArea.onChanged listener parameter should be a Record #85

Closed Vinnl closed 1 year ago

Vinnl commented 1 year ago

According to MDN, the first parameter to the listener

contains one property for each key that changed. The name of the property is the name of the key that changed, and its value is a storage.StorageChange object describing the change to that item.

In other words, a Record<string, StorageChange>.

However, in the type definitions, it looks like the parameter itself is the StorageChange type directly, rather than in a Record:

Autocomplete when accessing the first parameter to `addListener`, showing available properties `oldValue` and `newValue`, which should only be available on nested properties.

Not sure if I should report this in this repo, or if I need to report it somewhere for the upstream schemas - would appreciate pointers if it's the latter.

Lusito commented 1 year ago

That looks like incorrect indeed. Thanks for the report. I am honestly not sure, if this is a problem of the schemas or my misunderstanding of the schemas. I will take a look.

Aside from that: it's really difficult to make changes to the schema files, as you'll have to get into mozillas versioning tools. I've tried a while back and concluded, that I'd rather make fixes here.

Lusito commented 1 year ago

It seems it was my misunderstanding of the schemas. Will be fixed in the next version.

Vinnl commented 1 year ago

Fantastic, thank you so much!