From 13f586b0a2f32d7d999433ab982a29ea58133221 Mon Sep 17 00:00:00 2001 From: Tom Lagier Date: Tue, 4 Jul 2017 14:29:07 -0700 Subject: [PATCH] docs: Added Typescript integration to the readme (#79) --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 02e987a..71abfaa 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,24 @@ self.postMessage({foo: 'foo'}) self.addEventListener('message', (event) => { console.log(event); }); ``` +### Integrating with TypeScript + +To integrate with TypeScript, you will need to define a custom module for the exports of your worker. You will also need to cast the new worker as the `Worker` type: + +**typings/custom.d.ts** +``` +declare module "worker-loader!*" { + const content: any; + export = content; +} +``` + +**App.ts** +``` +import * as MyWorker from "worker-loader!../../worker"; +const worker: Worker = new MyWorker(); +``` +

Maintainers