Open ahardin13 opened 5 years ago
It looks to me like this definition is what needs to be updated. https://github.com/microsoft/TypeScript/blob/00bf32ca3967b07e8663d0cd2b3e2bbf572da88b/lib/lib.webworker.d.ts#L2721
After digging through how the changes would be made, I found the typescript definition matches the w3c spec. https://w3c.github.io/ServiceWorker/#serviceworkerregistration
Any guidance on if I should follow-up on that spec or stick with the current definition and not use Chrome's implementation?
On MDN they write for Chrome:
Starting with Chrome 46, update() returns a promise that resolves with 'undefined' if the operation completed successfully or there was no update, and rejects if update failed. If the new worker ran but installation failed, the promise still resolves. Formerly, it raised an exception.
On MDN they write for Chrome:
Starting with Chrome 46, update() returns a promise that resolves with 'undefined' if the operation completed successfully or there was no update, and rejects if update failed. If the new worker ran but installation failed, the promise still resolves. Formerly, it raised an exception.
This seems to have changed. Running the update method in Chromium 77, I get a ServiceWorkerRegistration
object back.
Edit: Tried it in Firefox 69 as well, same result as in Chromium 77.
It looks like this need to be fixed here: https://github.com/microsoft/TypeScript-DOM-lib-generator
TypeScript Version: 3.4.3
Search Terms: ServiceWorkerRegistration Update
Code
Expected behavior:
result
is of typeServiceWorkerRegistration
andresult.installing
andresult.waiting
are valid. https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/updateActual behavior:
result
is of type void and tsc gives errorserror TS2339: Property 'installing' does not exist on type 'void'.
error TS2339: Property 'waiting' does not exist on type 'void'.
[Playground Link](https://www.typescriptlang.org/play/#src=let%20isUpdating%3A%20boolean%3B%0D%0Anavigator.serviceWorker.getRegistration().then(sw%20%3D%3E%20%7B%0D%0A%20%20%20%20sw.update().then(result%20%3D%3E%20%7B%0D%0A%20%20%20%20%20%20%20%20if%20(result.installing%20%7C%7C%20result.waiting)%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20isUpdating%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%7D)%3B%0D%0A%7D)%3B%0D%0A)
Related Issues: https://github.com/microsoft/TypeScript/issues/17590