Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.

Commit 25a2e26

Browse files
committed
Post finished 🚀
1 parent b983ea3 commit 25a2e26

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

_drafts/2020-08-10-webpack-workbox-service-worker-typescript.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,10 @@ googleAnalytics.initialize()
216216
//...other code...
217217
```
218218

219-
...strict types + tslint + google analytics...
219+
One important thing to be noted here is that in my project I'm using TypeScript with the strict types activated and ESLint. As a consequence of this fact I have to add two things to the code we saw above:
220+
221+
* add a declaration in order to let TypeScript know that `self` is a `ServiceWorkerGlobalScope`
222+
* a `@ts-ignore` annotation to let typescript know that the `__WB_MANIFEST` will be available at compile time (Webpack bundling), and an additional `eslint-disable-next-line @typescript-eslint/ban-ts-comment` comment to avoid ESLint complaining about the `@tsignore` comment. :laughing:
220223

221224
```typescript
222225
//...other code...
@@ -236,4 +239,4 @@ precacheAndRoute(self.__WB_MANIFEST)
236239

237240
#### Conclusion
238241

239-
...conclusion
242+
As you can see, writing a service worker with Typescript is really easy. During the last time during my daily job I'm basically doing more and more web development instead of mobile apps. I feel like I'm almost reaching the mythological status of the "fullstack developer". :laughing: I hope that one day I will be able to share all my knowledge on web development and mobile development in all the company (and also be able to confront with other developers on these topics), including PWAs. Let's see what the future holds for me.

0 commit comments

Comments
 (0)