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.
This commit is contained in:
Mark Wubben 2022-09-25 16:06:16 +01:00 committed by GitHub
parent 3ebe65cbeb
commit 48dcafa2b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 182 additions and 150 deletions

View file

@ -42,7 +42,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ts-version: [~4.7]
ts-version: [~4.7, ~4.8]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3

14
entrypoints/main.d.ts vendored
View file

@ -1,2 +1,12 @@
export * from './main.cjs';
export {default} from './main.cjs';
import type {TestFn} from '../types/test-fn.cjs';
export * from '../types/assertions.cjs';
export * from '../types/try-fn.cjs';
export * from '../types/test-fn.cjs';
export * from '../types/subscribable.cjs';
/** Call to declare a test, or chain to declare hooks or test modifiers */
declare const test: TestFn;
/** Call to declare a test, or chain to declare hooks or test modifiers */
export default test;

View file

@ -1,77 +1,6 @@
import type {URL} from 'node:url';
export namespace SharedWorker {
export type ProtocolIdentifier = 'ava-4';
export type FactoryOptions = {
negotiateProtocol <Data = unknown>(supported: readonly ['ava-4']): Protocol<Data>;
// Add overloads for additional protocols.
};
export type Factory = (options: FactoryOptions) => void;
export type Protocol<Data = unknown> = {
readonly initialData: Data;
readonly protocol: 'ava-4';
broadcast: (data: Data) => BroadcastMessage<Data>;
ready: () => Protocol<Data>;
subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
testWorkers: () => AsyncIterableIterator<TestWorker<Data>>;
};
export type BroadcastMessage<Data = unknown> = {
readonly id: string;
replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
};
export type PublishedMessage<Data = unknown> = {
readonly id: string;
replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
};
export type ReceivedMessage<Data = unknown> = {
readonly data: Data;
readonly id: string;
readonly testWorker: TestWorker;
reply: (data: Data) => PublishedMessage<Data>;
};
export type TestWorker<Data = unknown> = {
readonly id: string;
readonly file: string;
publish: (data: Data) => PublishedMessage<Data>;
subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
teardown: (fn: (() => Promise<void>) | (() => void)) => () => Promise<void>;
};
export namespace Plugin {
export type RegistrationOptions<Identifier extends ProtocolIdentifier, Data = unknown> = {
readonly filename: string | URL;
readonly initialData?: Data;
readonly supportedProtocols: readonly Identifier[];
readonly teardown?: () => void;
};
export type Protocol<Data = unknown> = {
readonly available: Promise<void>;
readonly currentlyAvailable: boolean;
readonly protocol: 'ava-4';
publish: (data: Data) => PublishedMessage<Data>;
subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
};
export type PublishedMessage<Data = unknown> = {
readonly id: string;
replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
};
export type ReceivedMessage<Data = unknown> = {
readonly data: Data;
readonly id: string;
reply: (data: Data) => PublishedMessage<Data>;
};
}
}
import type {SharedWorker} from '../types/shared-worker.cjs';
export function registerSharedWorker<Data = unknown>(options: SharedWorker.Plugin.RegistrationOptions<'ava-4', Data>): SharedWorker.Plugin.Protocol<Data>;
// Add overloads for additional protocols.
export type {SharedWorker} from '../types/shared-worker.cjs';

View file

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

135
package-lock.json generated
View file

@ -11,7 +11,7 @@
"dependencies": {
"acorn": "^8.8.0",
"acorn-walk": "^8.2.0",
"ansi-styles": "^6.1.0",
"ansi-styles": "^6.1.1",
"arrgv": "^1.0.2",
"arrify": "^3.0.0",
"callsites": "^4.0.0",
@ -19,7 +19,7 @@
"chalk": "^5.0.1",
"chokidar": "^3.5.3",
"chunkd": "^2.0.1",
"ci-info": "^3.3.2",
"ci-info": "^3.4.0",
"ci-parallel-vars": "^1.0.1",
"clean-yaml-object": "^0.1.0",
"cli-truncate": "^3.1.0",
@ -29,7 +29,7 @@
"currently-unhandled": "^0.4.1",
"debug": "^4.3.4",
"del": "^7.0.0",
"emittery": "^0.13.1",
"emittery": "^1.0.0",
"figures": "^5.0.0",
"globby": "^13.1.2",
"ignore-by-default": "^2.1.0",
@ -63,7 +63,7 @@
"@ava/typescript": "^3.0.1",
"@sindresorhus/tsconfig": "^3.0.1",
"@sinonjs/fake-timers": "^9.1.2",
"ansi-escapes": "^5.0.0",
"ansi-escapes": "^6.0.0",
"c8": "^7.12.0",
"delay": "^5.0.0",
"execa": "^6.1.0",
@ -75,9 +75,9 @@
"temp-write": "^5.0.0",
"tempy": "^3.0.0",
"touch": "^3.1.0",
"tsd": "^0.22.0",
"typescript": "^4.7.3",
"xo": "^0.52.2",
"tsd": "^0.24.1",
"typescript": "^4.8.3",
"xo": "^0.52.3",
"zen-observable": "^0.8.15"
},
"engines": {
@ -1149,14 +1149,10 @@
"dev": true
},
"node_modules/@tsd/typescript": {
"version": "4.7.4",
"resolved": "https://registry.npmjs.org/@tsd/typescript/-/typescript-4.7.4.tgz",
"integrity": "sha512-jbtC+RgKZ9Kk65zuRZbKLTACf+tvFW4Rfq0JEMXrlmV3P3yme+Hm+pnb5fJRyt61SjIitcrC810wj7+1tgsEmg==",
"dev": true,
"bin": {
"tsc": "typescript/bin/tsc",
"tsserver": "typescript/bin/tsserver"
}
"version": "4.8.3",
"resolved": "https://registry.npmjs.org/@tsd/typescript/-/typescript-4.8.3.tgz",
"integrity": "sha512-ytRZWmXF0i4VFSG8NQ67NUDQ3NGe3E4oByFrxH8eJyW5uBOM5juIdXCg81OY/IcK81qHCzrvGEo8tujlIQbexw==",
"dev": true
},
"node_modules/@types/eslint": {
"version": "7.29.0",
@ -1489,15 +1485,27 @@
}
},
"node_modules/ansi-escapes": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-5.0.0.tgz",
"integrity": "sha512-5GFMVX8HqE/TB+FuBJGuO5XG0WrsA6ptUqoODaT/n9mmUaZFkqnBueB4leqGBCmrUHnCnC4PCZTCd0E7QQ83bA==",
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-6.0.0.tgz",
"integrity": "sha512-IG23inYII3dWlU2EyiAiGj6Bwal5GzsgPMwjYGvc1HPE2dgbj4ZB5ToWBKSquKw74nB3TIuOwaI6/jSULzfgrw==",
"dev": true,
"dependencies": {
"type-fest": "^1.0.2"
"type-fest": "^3.0.0"
},
"engines": {
"node": ">=12"
"node": ">=14.16"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/ansi-escapes/node_modules/type-fest": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-3.0.0.tgz",
"integrity": "sha512-MINvUN5ug9u+0hJDzSZNSnuKXI8M4F5Yvb6SQZ2CYqe7SgKXKOosEcU5R7tRgo85I6eAVBbkVF7TCvB4AUK2xQ==",
"dev": true,
"engines": {
"node": ">=14.16"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
@ -1515,9 +1523,9 @@
}
},
"node_modules/ansi-styles": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.1.0.tgz",
"integrity": "sha512-VbqNsoz55SYGczauuup0MFUyXNQviSpFTj1RQtFzmQLk18qbVSpTFFGMT293rmDaQuKCT6InmbuEyUne4mTuxQ==",
"version": "6.1.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.1.1.tgz",
"integrity": "sha512-qDOv24WjnYuL+wbwHdlsYZFy+cgPtrYw0Tn7GLORicQp9BkQLzrgI3Pm4VyR9ERZ41YTn7KlMPuL1n05WdZvmg==",
"engines": {
"node": ">=12"
},
@ -2004,9 +2012,9 @@
"integrity": "sha512-7d58XsFmOq0j6el67Ug9mHf9ELUXsQXYJBkyxhH/k+6Ke0qXRnv0kbemx+Twc6fRJ07C49lcbdgm9FL1Ei/6SQ=="
},
"node_modules/ci-info": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.3.2.tgz",
"integrity": "sha512-xmDt/QIAdeZ9+nfdPsaBCpMvHNLFiLdjj59qjqn+6iPe6YmHGQ35sBnQ8uslRBXFmXkiZQOJRjvQeoGppoTjjg=="
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.4.0.tgz",
"integrity": "sha512-t5QdPT5jq3o262DOQ8zA6E1tlH2upmUc4Hlvrbx1pGYJuiiHl7O7rvVNI+l8HTVhd/q3Qc9vqimkNk5yiXsAug=="
},
"node_modules/ci-parallel-vars": {
"version": "1.0.1",
@ -2478,11 +2486,11 @@
"dev": true
},
"node_modules/emittery": {
"version": "0.13.1",
"resolved": "https://registry.npmjs.org/emittery/-/emittery-0.13.1.tgz",
"integrity": "sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==",
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/emittery/-/emittery-1.0.0.tgz",
"integrity": "sha512-TD/u5aAn5W2HI2OukSIReNYXf/cH7U0QZHPxM4aIVYy0CmtrLCvf+7E8MuV2BbO02l6wq4sAKuFA8H16l6AHMA==",
"engines": {
"node": ">=12"
"node": ">=14.16"
},
"funding": {
"url": "https://github.com/sindresorhus/emittery?sponsor=1"
@ -9725,12 +9733,12 @@
}
},
"node_modules/tsd": {
"version": "0.22.0",
"resolved": "https://registry.npmjs.org/tsd/-/tsd-0.22.0.tgz",
"integrity": "sha512-NH+tfEDQ0Ze8gH7TorB6IxYybD+M68EYawe45YNVrbQcydNBfdQHP9IiD0QbnqmwNXrv+l9GAiULT68mo4q/xA==",
"version": "0.24.1",
"resolved": "https://registry.npmjs.org/tsd/-/tsd-0.24.1.tgz",
"integrity": "sha512-sD+s81/2aM4RRhimCDttd4xpBNbUFWnoMSHk/o8kC8Ek23jljeRNWjsxFJmOmYLuLTN9swRt1b6iXfUXTcTiIA==",
"dev": true,
"dependencies": {
"@tsd/typescript": "~4.7.4",
"@tsd/typescript": "~4.8.3",
"eslint-formatter-pretty": "^4.1.0",
"globby": "^11.0.1",
"meow": "^9.0.0",
@ -9807,9 +9815,9 @@
}
},
"node_modules/typescript": {
"version": "4.8.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.2.tgz",
"integrity": "sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==",
"version": "4.8.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz",
"integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
@ -10249,9 +10257,9 @@
}
},
"node_modules/xo": {
"version": "0.52.2",
"resolved": "https://registry.npmjs.org/xo/-/xo-0.52.2.tgz",
"integrity": "sha512-FTvJb6P6w1h3tu5jy3firRyLSqvJSHeffajpZ05RP4Xe0OUJkQzcwwOEF9/VUHC7lTBPnOrewEGJzQo8Mujx3Q==",
"version": "0.52.3",
"resolved": "https://registry.npmjs.org/xo/-/xo-0.52.3.tgz",
"integrity": "sha512-liCEteZ5z+QRyh3XzsYWQyxedBHBvx8CDlNvvi+BJz74L0E5/ID2v7JtoX3bD541AlMuOy4e/iWif6hhNGBFNw==",
"bundleDependencies": [
"@typescript-eslint/eslint-plugin",
"@typescript-eslint/parser",
@ -10348,14 +10356,14 @@
"license": "MIT"
},
"node_modules/xo/node_modules/@typescript-eslint/eslint-plugin": {
"version": "5.35.1",
"version": "5.36.1",
"dev": true,
"inBundle": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/scope-manager": "5.35.1",
"@typescript-eslint/type-utils": "5.35.1",
"@typescript-eslint/utils": "5.35.1",
"@typescript-eslint/scope-manager": "5.36.1",
"@typescript-eslint/type-utils": "5.36.1",
"@typescript-eslint/utils": "5.36.1",
"debug": "^4.3.4",
"functional-red-black-tree": "^1.0.1",
"ignore": "^5.2.0",
@ -10381,14 +10389,14 @@
}
},
"node_modules/xo/node_modules/@typescript-eslint/parser": {
"version": "5.35.1",
"version": "5.36.1",
"dev": true,
"inBundle": true,
"license": "BSD-2-Clause",
"dependencies": {
"@typescript-eslint/scope-manager": "5.35.1",
"@typescript-eslint/types": "5.35.1",
"@typescript-eslint/typescript-estree": "5.35.1",
"@typescript-eslint/scope-manager": "5.36.1",
"@typescript-eslint/types": "5.36.1",
"@typescript-eslint/typescript-estree": "5.36.1",
"debug": "^4.3.4"
},
"engines": {
@ -10408,13 +10416,13 @@
}
},
"node_modules/xo/node_modules/@typescript-eslint/scope-manager": {
"version": "5.35.1",
"version": "5.36.1",
"dev": true,
"inBundle": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/types": "5.35.1",
"@typescript-eslint/visitor-keys": "5.35.1"
"@typescript-eslint/types": "5.36.1",
"@typescript-eslint/visitor-keys": "5.36.1"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@ -10425,12 +10433,13 @@
}
},
"node_modules/xo/node_modules/@typescript-eslint/type-utils": {
"version": "5.35.1",
"version": "5.36.1",
"dev": true,
"inBundle": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/utils": "5.35.1",
"@typescript-eslint/typescript-estree": "5.36.1",
"@typescript-eslint/utils": "5.36.1",
"debug": "^4.3.4",
"tsutils": "^3.21.0"
},
@ -10451,7 +10460,7 @@
}
},
"node_modules/xo/node_modules/@typescript-eslint/types": {
"version": "5.35.1",
"version": "5.36.1",
"dev": true,
"inBundle": true,
"license": "MIT",
@ -10464,13 +10473,13 @@
}
},
"node_modules/xo/node_modules/@typescript-eslint/typescript-estree": {
"version": "5.35.1",
"version": "5.36.1",
"dev": true,
"inBundle": true,
"license": "BSD-2-Clause",
"dependencies": {
"@typescript-eslint/types": "5.35.1",
"@typescript-eslint/visitor-keys": "5.35.1",
"@typescript-eslint/types": "5.36.1",
"@typescript-eslint/visitor-keys": "5.36.1",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
@ -10520,15 +10529,15 @@
}
},
"node_modules/xo/node_modules/@typescript-eslint/utils": {
"version": "5.35.1",
"version": "5.36.1",
"dev": true,
"inBundle": true,
"license": "MIT",
"dependencies": {
"@types/json-schema": "^7.0.9",
"@typescript-eslint/scope-manager": "5.35.1",
"@typescript-eslint/types": "5.35.1",
"@typescript-eslint/typescript-estree": "5.35.1",
"@typescript-eslint/scope-manager": "5.36.1",
"@typescript-eslint/types": "5.36.1",
"@typescript-eslint/typescript-estree": "5.36.1",
"eslint-scope": "^5.1.1",
"eslint-utils": "^3.0.0"
},
@ -10544,12 +10553,12 @@
}
},
"node_modules/xo/node_modules/@typescript-eslint/visitor-keys": {
"version": "5.35.1",
"version": "5.36.1",
"dev": true,
"inBundle": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/types": "5.35.1",
"@typescript-eslint/types": "5.36.1",
"eslint-visitor-keys": "^3.3.0"
},
"engines": {

View file

@ -83,7 +83,7 @@
"dependencies": {
"acorn": "^8.8.0",
"acorn-walk": "^8.2.0",
"ansi-styles": "^6.1.0",
"ansi-styles": "^6.1.1",
"arrgv": "^1.0.2",
"arrify": "^3.0.0",
"callsites": "^4.0.0",
@ -91,7 +91,7 @@
"chalk": "^5.0.1",
"chokidar": "^3.5.3",
"chunkd": "^2.0.1",
"ci-info": "^3.3.2",
"ci-info": "^3.4.0",
"ci-parallel-vars": "^1.0.1",
"clean-yaml-object": "^0.1.0",
"cli-truncate": "^3.1.0",
@ -101,7 +101,7 @@
"currently-unhandled": "^0.4.1",
"debug": "^4.3.4",
"del": "^7.0.0",
"emittery": "^0.13.1",
"emittery": "^1.0.0",
"figures": "^5.0.0",
"globby": "^13.1.2",
"ignore-by-default": "^2.1.0",
@ -132,7 +132,7 @@
"@ava/typescript": "^3.0.1",
"@sindresorhus/tsconfig": "^3.0.1",
"@sinonjs/fake-timers": "^9.1.2",
"ansi-escapes": "^5.0.0",
"ansi-escapes": "^6.0.0",
"c8": "^7.12.0",
"delay": "^5.0.0",
"execa": "^6.1.0",
@ -144,9 +144,9 @@
"temp-write": "^5.0.0",
"tempy": "^3.0.0",
"touch": "^3.1.0",
"tsd": "^0.22.0",
"typescript": "^4.7.3",
"xo": "^0.52.2",
"tsd": "^0.24.1",
"typescript": "^4.8.3",
"xo": "^0.52.3",
"zen-observable": "^0.8.15"
},
"peerDependencies": {

View file

@ -48,7 +48,7 @@ import {expectType} from 'tsd';
// @ts-expect-error TS2345
t.is(input, expected);
},
title(_providedTitle, input, expected) {
title(_providedTitle, input: string, expected: number) {
expectType<string>(input);
expectType<number>(expected);
return 'title';

View file

@ -49,7 +49,7 @@ import {expectType} from 'tsd';
// @ts-expect-error TS2345
t.is(input, expected);
},
title(_providedTitle, input, expected) {
title(_providedTitle, input: string, expected: number) {
expectType<string>(input);
expectType<number>(expected);
return 'title';

View file

@ -1,5 +1,10 @@
{
"extends": "@sindresorhus/tsconfig",
"compilerOptions": {
// See <https://github.com/microsoft/TypeScript/issues/50544>. This does not
// seem solved with 4.8.3.
"forceConsistentCasingInFileNames": false,
},
"include": [
"test",
"test-tap",

74
types/shared-worker.d.cts Normal file
View file

@ -0,0 +1,74 @@
import type {URL} from 'node:url';
export namespace SharedWorker {
export type ProtocolIdentifier = 'ava-4';
export type FactoryOptions = {
negotiateProtocol <Data = unknown>(supported: readonly ['ava-4']): Protocol<Data>;
// Add overloads for additional protocols.
};
export type Factory = (options: FactoryOptions) => void;
export type Protocol<Data = unknown> = {
readonly initialData: Data;
readonly protocol: 'ava-4';
broadcast: (data: Data) => BroadcastMessage<Data>;
ready: () => Protocol<Data>;
subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
testWorkers: () => AsyncIterableIterator<TestWorker<Data>>;
};
export type BroadcastMessage<Data = unknown> = {
readonly id: string;
replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
};
export type PublishedMessage<Data = unknown> = {
readonly id: string;
replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
};
export type ReceivedMessage<Data = unknown> = {
readonly data: Data;
readonly id: string;
readonly testWorker: TestWorker;
reply: (data: Data) => PublishedMessage<Data>;
};
export type TestWorker<Data = unknown> = {
readonly id: string;
readonly file: string;
publish: (data: Data) => PublishedMessage<Data>;
subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
teardown: (fn: (() => Promise<void>) | (() => void)) => () => Promise<void>;
};
export namespace Plugin {
export type RegistrationOptions<Identifier extends ProtocolIdentifier, Data = unknown> = {
readonly filename: string | URL;
readonly initialData?: Data;
readonly supportedProtocols: readonly Identifier[];
readonly teardown?: () => void;
};
export type Protocol<Data = unknown> = {
readonly available: Promise<void>;
readonly currentlyAvailable: boolean;
readonly protocol: 'ava-4';
publish: (data: Data) => PublishedMessage<Data>;
subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
};
export type PublishedMessage<Data = unknown> = {
readonly id: string;
replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
};
export type ReceivedMessage<Data = unknown> = {
readonly data: Data;
readonly id: string;
reply: (data: Data) => PublishedMessage<Data>;
};
}
}