Skip to content

Add types for Service Worker Controller #673

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

Merged
merged 10 commits into from
Apr 12, 2018
Merged

Conversation

mmermerkaya
Copy link
Contributor

Also updates TypeScript to 2.8.1, which has much better WebWorker and Notification typings, which allowed me to remove some more "any" casts.

Updates TypeScript to 2.8.1, which has much better WebWorker and Notification typings

// Not the whole interface, just the parts we're currently using.
// If TS claims that something does not exist on this, feel free to add it.
interface ServiceWorkerGlobalScope {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this not already exist as a TSLib?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It exists (as a type definition file), but it can't be used simultaneously with DOM.

microsoft/TypeScript#20595
microsoft/TypeScript#14687

So I took some parts of it that we need (and doesn't conflict with DOM) and put them here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough. Let's just add a link to the actual file and keep an eye on if we can undo this in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added link.

Copy link
Contributor

@jshcrowthe jshcrowthe left a comment

Choose a reason for hiding this comment

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

Oops, just noticed the typescript update. Lets go ahead and pull that from this PR and do it in a separate one for the whole repo?

const FCM_MSG = 'FCM_MSG';

export type BgMessageHandler = (input: any) => Promise<any>;
export type BgMessageHandler = (input: Payload) => void;

Choose a reason for hiding this comment

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

You could be expecting a promise to be returned here so you can pass the promise to event.waitUntil(). Otherwise the service worker could be terminated before the developers work has finished.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point, thanks!

@mmermerkaya
Copy link
Contributor Author

Created #676 for dependency upgrades.

This reverts commit 306f97c.

Forgot to run `yarn` after switching branches, which made the push hook run the updated version of prettier, which created this commit.
Copy link
Contributor

@jshcrowthe jshcrowthe left a comment

Choose a reason for hiding this comment

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

Great, after we get tests passing this LGTM 👍

@mmermerkaya
Copy link
Contributor Author

They should pass once #676 is merged.

@mmermerkaya mmermerkaya merged commit 27a77fd into master Apr 12, 2018
@mmermerkaya mmermerkaya deleted the mmermerkaya-sw-types branch April 12, 2018 21:49
@firebase firebase locked and limited conversation to collaborators Oct 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants