Skip to content

Commit 48dcafa

Browse files
authored
Update dependencies; more type tweaks
* Upgrade to TypeScript 4.8. Keep testing with 4.7 to ensure backwards compatibility. * Update dev dependencies * Update dependencies * Tweak type definitions used in exports map for TS 4.8 compatibility. Duplicate and export shared types where appropriate, but don't export from the other export file since it seems to confuse things.
1 parent 3ebe65c commit 48dcafa

File tree

10 files changed

+182
-150
lines changed

10 files changed

+182
-150
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
runs-on: ubuntu-latest
4343
strategy:
4444
matrix:
45-
ts-version: [~4.7]
45+
ts-version: [~4.7, ~4.8]
4646
steps:
4747
- uses: actions/checkout@v3
4848
- uses: actions/setup-node@v3

entrypoints/main.d.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
1-
export * from './main.cjs';
2-
export {default} from './main.cjs';
1+
import type {TestFn} from '../types/test-fn.cjs';
2+
3+
export * from '../types/assertions.cjs';
4+
export * from '../types/try-fn.cjs';
5+
export * from '../types/test-fn.cjs';
6+
export * from '../types/subscribable.cjs';
7+
8+
/** Call to declare a test, or chain to declare hooks or test modifiers */
9+
declare const test: TestFn;
10+
11+
/** Call to declare a test, or chain to declare hooks or test modifiers */
12+
export default test;

entrypoints/plugin.d.cts

+3-74
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,6 @@
1-
import type {URL} from 'node:url';
2-
3-
export namespace SharedWorker {
4-
export type ProtocolIdentifier = 'ava-4';
5-
6-
export type FactoryOptions = {
7-
negotiateProtocol <Data = unknown>(supported: readonly ['ava-4']): Protocol<Data>;
8-
// Add overloads for additional protocols.
9-
};
10-
11-
export type Factory = (options: FactoryOptions) => void;
12-
13-
export type Protocol<Data = unknown> = {
14-
readonly initialData: Data;
15-
readonly protocol: 'ava-4';
16-
broadcast: (data: Data) => BroadcastMessage<Data>;
17-
ready: () => Protocol<Data>;
18-
subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
19-
testWorkers: () => AsyncIterableIterator<TestWorker<Data>>;
20-
};
21-
22-
export type BroadcastMessage<Data = unknown> = {
23-
readonly id: string;
24-
replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
25-
};
26-
27-
export type PublishedMessage<Data = unknown> = {
28-
readonly id: string;
29-
replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
30-
};
31-
32-
export type ReceivedMessage<Data = unknown> = {
33-
readonly data: Data;
34-
readonly id: string;
35-
readonly testWorker: TestWorker;
36-
reply: (data: Data) => PublishedMessage<Data>;
37-
};
38-
39-
export type TestWorker<Data = unknown> = {
40-
readonly id: string;
41-
readonly file: string;
42-
publish: (data: Data) => PublishedMessage<Data>;
43-
subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
44-
teardown: (fn: (() => Promise<void>) | (() => void)) => () => Promise<void>;
45-
};
46-
47-
export namespace Plugin {
48-
export type RegistrationOptions<Identifier extends ProtocolIdentifier, Data = unknown> = {
49-
readonly filename: string | URL;
50-
readonly initialData?: Data;
51-
readonly supportedProtocols: readonly Identifier[];
52-
readonly teardown?: () => void;
53-
};
54-
55-
export type Protocol<Data = unknown> = {
56-
readonly available: Promise<void>;
57-
readonly currentlyAvailable: boolean;
58-
readonly protocol: 'ava-4';
59-
publish: (data: Data) => PublishedMessage<Data>;
60-
subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
61-
};
62-
63-
export type PublishedMessage<Data = unknown> = {
64-
readonly id: string;
65-
replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
66-
};
67-
68-
export type ReceivedMessage<Data = unknown> = {
69-
readonly data: Data;
70-
readonly id: string;
71-
reply: (data: Data) => PublishedMessage<Data>;
72-
};
73-
}
74-
}
1+
import type {SharedWorker} from '../types/shared-worker.cjs';
752

763
export function registerSharedWorker<Data = unknown>(options: SharedWorker.Plugin.RegistrationOptions<'ava-4', Data>): SharedWorker.Plugin.Protocol<Data>;
774
// Add overloads for additional protocols.
5+
6+
export type {SharedWorker} from '../types/shared-worker.cjs';

entrypoints/plugin.d.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
export type * from './plugin.cjs';
1+
import type {SharedWorker} from '../types/shared-worker.cjs';
2+
3+
export function registerSharedWorker<Data = unknown>(options: SharedWorker.Plugin.RegistrationOptions<'ava-4', Data>): SharedWorker.Plugin.Protocol<Data>;
4+
// Add overloads for additional protocols.
5+
6+
export type {SharedWorker} from '../types/shared-worker.cjs';

0 commit comments

Comments
 (0)