Skip to content

Commit

Permalink
feat: add worker lib .d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemain committed Jan 10, 2024
1 parent 6bb3730 commit 135acaa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/global/types/lib.worker.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface MiniProgramWorker {
onMessage<T = Record<string, unknown>>(cb: (message: T) => void): void;
postMessage<T = Record<string, unknown>>(message: T): void;
}

declare var worker: MiniProgramWorker;
7 changes: 7 additions & 0 deletions tests/global/worker.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { MiniProgramWorker } from '../../packages/global/types/lib.worker';
import { expectAssignable } from 'tsd-lite';

declare const worker: MiniProgramWorker;

expectAssignable<(cb: (evt: any) => any) => any>(worker.onMessage);
expectAssignable<(message: any) => any>(worker.postMessage);

0 comments on commit 135acaa

Please sign in to comment.