diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 56239e0c1..3f2fa30ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/entrypoints/main.d.ts b/entrypoints/main.d.ts index 6120bb890..d4fcdc160 100644 --- a/entrypoints/main.d.ts +++ b/entrypoints/main.d.ts @@ -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; diff --git a/entrypoints/plugin.d.cts b/entrypoints/plugin.d.cts index 24319ce25..9e5871101 100644 --- a/entrypoints/plugin.d.cts +++ b/entrypoints/plugin.d.cts @@ -1,77 +1,6 @@ -import type {URL} from 'node:url'; - -export namespace SharedWorker { - export type ProtocolIdentifier = 'ava-4'; - - export type FactoryOptions = { - negotiateProtocol (supported: readonly ['ava-4']): Protocol; - // Add overloads for additional protocols. - }; - - export type Factory = (options: FactoryOptions) => void; - - export type Protocol = { - readonly initialData: Data; - readonly protocol: 'ava-4'; - broadcast: (data: Data) => BroadcastMessage; - ready: () => Protocol; - subscribe: () => AsyncIterableIterator>; - testWorkers: () => AsyncIterableIterator>; - }; - - export type BroadcastMessage = { - readonly id: string; - replies: () => AsyncIterableIterator>; - }; - - export type PublishedMessage = { - readonly id: string; - replies: () => AsyncIterableIterator>; - }; - - export type ReceivedMessage = { - readonly data: Data; - readonly id: string; - readonly testWorker: TestWorker; - reply: (data: Data) => PublishedMessage; - }; - - export type TestWorker = { - readonly id: string; - readonly file: string; - publish: (data: Data) => PublishedMessage; - subscribe: () => AsyncIterableIterator>; - teardown: (fn: (() => Promise) | (() => void)) => () => Promise; - }; - - export namespace Plugin { - export type RegistrationOptions = { - readonly filename: string | URL; - readonly initialData?: Data; - readonly supportedProtocols: readonly Identifier[]; - readonly teardown?: () => void; - }; - - export type Protocol = { - readonly available: Promise; - readonly currentlyAvailable: boolean; - readonly protocol: 'ava-4'; - publish: (data: Data) => PublishedMessage; - subscribe: () => AsyncIterableIterator>; - }; - - export type PublishedMessage = { - readonly id: string; - replies: () => AsyncIterableIterator>; - }; - - export type ReceivedMessage = { - readonly data: Data; - readonly id: string; - reply: (data: Data) => PublishedMessage; - }; - } -} +import type {SharedWorker} from '../types/shared-worker.cjs'; export function registerSharedWorker(options: SharedWorker.Plugin.RegistrationOptions<'ava-4', Data>): SharedWorker.Plugin.Protocol; // Add overloads for additional protocols. + +export type {SharedWorker} from '../types/shared-worker.cjs'; diff --git a/entrypoints/plugin.d.ts b/entrypoints/plugin.d.ts index e84a66433..9e5871101 100644 --- a/entrypoints/plugin.d.ts +++ b/entrypoints/plugin.d.ts @@ -1 +1,6 @@ -export type * from './plugin.cjs'; +import type {SharedWorker} from '../types/shared-worker.cjs'; + +export function registerSharedWorker(options: SharedWorker.Plugin.RegistrationOptions<'ava-4', Data>): SharedWorker.Plugin.Protocol; +// Add overloads for additional protocols. + +export type {SharedWorker} from '../types/shared-worker.cjs'; diff --git a/package-lock.json b/package-lock.json index 629fd935a..0957b6e22 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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": { diff --git a/package.json b/package.json index eea1e8967..95a056238 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/test-types/import-in-cts/macros.cts b/test-types/import-in-cts/macros.cts index f775ed7aa..b8b8a8f47 100644 --- a/test-types/import-in-cts/macros.cts +++ b/test-types/import-in-cts/macros.cts @@ -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(input); expectType(expected); return 'title'; diff --git a/test-types/module/macros.ts b/test-types/module/macros.ts index 220438756..f4fe2d667 100644 --- a/test-types/module/macros.ts +++ b/test-types/module/macros.ts @@ -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(input); expectType(expected); return 'title'; diff --git a/tsconfig.json b/tsconfig.json index 5c8401b8f..d59b5984c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,10 @@ { "extends": "@sindresorhus/tsconfig", + "compilerOptions": { + // See . This does not + // seem solved with 4.8.3. + "forceConsistentCasingInFileNames": false, + }, "include": [ "test", "test-tap", diff --git a/types/shared-worker.d.cts b/types/shared-worker.d.cts new file mode 100644 index 000000000..bcb57d99c --- /dev/null +++ b/types/shared-worker.d.cts @@ -0,0 +1,74 @@ +import type {URL} from 'node:url'; + +export namespace SharedWorker { + export type ProtocolIdentifier = 'ava-4'; + + export type FactoryOptions = { + negotiateProtocol (supported: readonly ['ava-4']): Protocol; + // Add overloads for additional protocols. + }; + + export type Factory = (options: FactoryOptions) => void; + + export type Protocol = { + readonly initialData: Data; + readonly protocol: 'ava-4'; + broadcast: (data: Data) => BroadcastMessage; + ready: () => Protocol; + subscribe: () => AsyncIterableIterator>; + testWorkers: () => AsyncIterableIterator>; + }; + + export type BroadcastMessage = { + readonly id: string; + replies: () => AsyncIterableIterator>; + }; + + export type PublishedMessage = { + readonly id: string; + replies: () => AsyncIterableIterator>; + }; + + export type ReceivedMessage = { + readonly data: Data; + readonly id: string; + readonly testWorker: TestWorker; + reply: (data: Data) => PublishedMessage; + }; + + export type TestWorker = { + readonly id: string; + readonly file: string; + publish: (data: Data) => PublishedMessage; + subscribe: () => AsyncIterableIterator>; + teardown: (fn: (() => Promise) | (() => void)) => () => Promise; + }; + + export namespace Plugin { + export type RegistrationOptions = { + readonly filename: string | URL; + readonly initialData?: Data; + readonly supportedProtocols: readonly Identifier[]; + readonly teardown?: () => void; + }; + + export type Protocol = { + readonly available: Promise; + readonly currentlyAvailable: boolean; + readonly protocol: 'ava-4'; + publish: (data: Data) => PublishedMessage; + subscribe: () => AsyncIterableIterator>; + }; + + export type PublishedMessage = { + readonly id: string; + replies: () => AsyncIterableIterator>; + }; + + export type ReceivedMessage = { + readonly data: Data; + readonly id: string; + reply: (data: Data) => PublishedMessage; + }; + } +}