Skip to content

Commit

Permalink
feat: add typescript definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Dec 10, 2018
1 parent 8050e85 commit 05456f5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
18 changes: 18 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
declare module 'web-worker-proxy' {
export function create(worker: Worker): any;

export function proxy(o: object, target?: Worker): { dispose(): void };

export function persist<T extends Function>(
fn: T
): {
type: string;
apply(
that: any,
args: T extends (...args: infer A) => any ? A : never
): ReturnType<T>;
dispose(): void;
on(name: 'dispose', cb: () => unknown): void;
disposed: boolean;
};
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
"web worker",
"proxy"
],
"types": "index.d.ts",
"main": "lib/index.js",
"files": [
"lib/"
"lib/",
"index.d.ts"
],
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/persist.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function persist<T: *>(func: (...args: T) => mixed) {
listeners.forEach(listener => listener());
disposed = true;
},
on(name: 'dispose', cb: Function) {
on(name: 'dispose', cb: () => mixed) {
if (name === 'dispose') {
listeners.push(cb);
}
Expand Down

0 comments on commit 05456f5

Please sign in to comment.