Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workbox event types #2156

Merged
merged 2 commits into from
Aug 1, 2019
Merged

Workbox event types #2156

merged 2 commits into from
Aug 1, 2019

Conversation

philipwalton
Copy link
Member

R: @jeffposnick

This PR adds some additional type information to address #2144. Primarily, it adds additional event callback types as well as a WorkboxEventMap interface so callbacks can declare their event callback argument types based on the event type passed to addEventListener().

This means developer code doesn't have to import the WorkboxEvent type and annotate their own callbacks -- the types are inferred from the event type listened to. (Note: I took this pattern from the built-in addEventListener() declaration, so I assume it's how these types of APIs are supposed to be typed.)

/cc @azizhk

@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@coveralls
Copy link

coveralls commented Aug 1, 2019

Coverage Status

Coverage remained the same at 78.731% when pulling 71bbe6a on workbox-event-types into fec46ef on master.

@azizhk
Copy link
Contributor

azizhk commented Aug 1, 2019

@googlebot I consent.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@azizhk
Copy link
Contributor

azizhk commented Aug 1, 2019

I took this pattern from the built-in addEventListener() declaration, so I assume it's how these types of APIs are supposed to be typed.

Wow, I did not know about this. I applied it to props as well. #2157. Makes it a little verbose, but up to you.

Copy link
Contributor

@jeffposnick jeffposnick left a comment

Choose a reason for hiding this comment

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

Just when I thought I understood TypeScript... thanks for working this out.

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@workbox-pr-bot
Copy link
Collaborator

PR-Bot Size Plugin

Changed File Sizes

File Before After Change GZipped
packages/workbox-window/build/workbox-window.dev.umd.js 31.88 KB 32.20 KB +1% 8.19 KB
packages/workbox-window/build/workbox-window.prod.umd.js 4.46 KB 4.54 KB +2% 1.88 KB

New Files

No new files have been added.

All File Sizes

View Table
File Before After Change GZipped
packages/workbox-background-sync/build/workbox-background-sync.prod.js 3.86 KB 3.86 KB 0% 1.59 KB
packages/workbox-broadcast-update/build/workbox-broadcast-update.prod.js 1.92 KB 1.92 KB 0% 959 B
packages/workbox-build/build/_types.js 41 B 41 B 0% 61 B
packages/workbox-build/build/index.js 3.30 KB 3.30 KB 0% 1.31 KB
packages/workbox-cacheable-response/build/workbox-cacheable-response.prod.js 594 B 594 B 0% 354 B
packages/workbox-cli/build/app.js 4.16 KB 4.16 KB 0% 1.64 KB
packages/workbox-cli/build/bin.js 940 B 940 B 0% 502 B
packages/workbox-core/build/workbox-core.prod.js 5.94 KB 5.94 KB 0% 2.46 KB
packages/workbox-expiration/build/workbox-expiration.prod.js 2.94 KB 2.94 KB 0% 1.27 KB
packages/workbox-google-analytics/build/workbox-offline-ga.prod.js 1.95 KB 1.95 KB 0% 913 B
packages/workbox-navigation-preload/build/workbox-navigation-preload.prod.js 660 B 660 B 0% 324 B
packages/workbox-precaching/build/workbox-precaching.prod.js 4.89 KB 4.89 KB 0% 1.90 KB
packages/workbox-range-requests/build/workbox-range-requests.prod.js 1.57 KB 1.57 KB 0% 797 B
packages/workbox-routing/build/workbox-routing.prod.js 3.09 KB 3.09 KB 0% 1.35 KB
packages/workbox-strategies/build/workbox-strategies.prod.js 4.10 KB 4.10 KB 0% 1.13 KB
packages/workbox-streams/build/workbox-streams.prod.js 1.46 KB 1.46 KB 0% 720 B
packages/workbox-sw/build/workbox-sw.js 1.34 KB 1.34 KB 0% 747 B
packages/workbox-webpack-plugin/build/generate-sw.js 3.71 KB 3.71 KB 0% 1.40 KB
packages/workbox-webpack-plugin/build/index.js 349 B 349 B 0% 255 B
packages/workbox-webpack-plugin/build/inject-manifest.js 4.68 KB 4.68 KB 0% 1.59 KB
packages/workbox-window/build/workbox-window.dev.umd.js 31.88 KB 32.20 KB +1% 8.19 KB
packages/workbox-window/build/workbox-window.prod.umd.js 4.46 KB 4.54 KB +2% 1.88 KB

Workbox Aggregate Size Plugin

3.5KB gzip'ed (23% of limit)
7.79KB uncompressed

@philipwalton philipwalton merged commit 178b5ab into master Aug 1, 2019
@philipwalton philipwalton deleted the workbox-event-types branch August 1, 2019 17:40
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.

6 participants