service worker typings

pull/5708/head
Niklas Fiekas 2019-11-30 12:06:59 +01:00
parent 5714aba919
commit a270acdb8c
4 changed files with 12 additions and 6 deletions

View File

@ -6,6 +6,7 @@
"author": "Thibault Duplessis",
"license": "AGPL-3.0",
"devDependencies": {
"@build/tsProject": "2.0.0"
"@build/tsProject": "2.0.0",
"types-serviceworker": "^0.0.1"
}
}

View File

@ -1,5 +1,5 @@
self.addEventListener('push', (event: any) => {
const data = event.data.json();
self.addEventListener('push', event => {
const data = event.data!.json();
return self.registration.showNotification(data.title, {
badge: 'https://lichess1.org/assets/images/logo.256.png',
icon: 'https://lichess1.org/assets/images/logo.256.png',
@ -10,14 +10,14 @@ self.addEventListener('push', (event: any) => {
});
});
self.addEventListener('notificationclick', (event: any) => {
self.addEventListener('notificationclick', event => {
event.waitUntil(self.registration.getNotifications().then(notifications => {
notifications.forEach(notification => notification.close());
return self.clients.matchAll({
type: 'window',
includeUncontrolled: true
});
}).then(windowClients => {
}).then((windowClients: WindowClient[]) => {
// determine url
const data = event.notification.data.userData;
let url = '/';

View File

@ -3,6 +3,6 @@
"include": ["src/*.ts"],
"lib": ["ES6"],
"compilerOptions": {
"noImplicitAny": false
"types": ["types-serviceworker"]
}
}

View File

@ -4900,6 +4900,11 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
types-serviceworker@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/types-serviceworker/-/types-serviceworker-0.0.1.tgz#3d356e176d3b987d2164b34e609c591e67d31f1c"
integrity sha512-EKO/SZ3AsHEZsqv+bsdlTCz5k955riOksnYGlG6JhVwNTVsPWj/TScTbiNVZ5+mmX8TcEXF0C8aSxUw0jTDpIw==
typescript@^3:
version "3.6.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.6.3.tgz#fea942fabb20f7e1ca7164ff626f1a9f3f70b4da"