yyx990803 / register-service-worker

A script to simplify service worker registration with hooks for common events.
MIT License
638 stars 58 forks source link

Semver violation: #17 / 1.6.0 breaks backward compatibility #23

Closed bodograumann closed 5 years ago

bodograumann commented 5 years ago

The pull request #17 adds a new required property registerOptions to the Hooks type. So now existing vue/typescript applications with the default registerServiceWorker.ts will fail to build with the following error:

ERROR in […]/src/registerServiceWorker.ts 6:56 Argument of type '{ ready(): void; registered(): void; cached(): void; updatefound(): void; updated(): void; offline(): void; error(error: Error): void; }' is not assignable to parameter of type 'Hooks'. Property 'registrationOptions' is missing in type '{ ready(): void; registered(): void; cached(): void; updatefound(): void; updated(): void; offline(): void; error(error: Error): void; }'.

Mister-Hope commented 5 years ago

Yes,and I can't even find any guide here

LinusBorg commented 5 years ago

That option isn't really a required property - it has a default value when unassigned:

https://github.com/yyx990803/register-service-worker/blob/master/src/index.js#L18-L19

So this is a bug in the types, no an intentionally breaking change of the API.

tlhunter commented 5 years ago

BTW, here's a raw diff of the published modules: https://diff.intrinsic.com/register-service-worker/1.5.2/1.6.0#file-index.js