From 1d30b3e8624eacab8f11033023883a8add37e602 Mon Sep 17 00:00:00 2001 From: Tom Mrazauskas Date: Wed, 27 Dec 2023 11:25:22 +0200 Subject: [PATCH] chore: migrate few more type tests to TSTyche (#14786) --- .eslintrc.cjs | 2 +- jest.config.ts.mjs | 3 ++ .../expect-utils/__typetests__/utils.test.ts | 44 +++++++++---------- packages/expect-utils/package.json | 4 +- .../{index.test.ts => jest-cli.test.ts} | 7 +-- packages/jest-cli/package.json | 4 +- packages/jest/__typetests__/jest.test.ts | 11 +++-- packages/jest/package.json | 4 -- tstyche.config.json | 7 ++- yarn.lock | 6 --- 10 files changed, 44 insertions(+), 48 deletions(-) rename packages/jest-cli/__typetests__/{index.test.ts => jest-cli.test.ts} (66%) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 5f417dceed58..512d5025b592 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -365,7 +365,7 @@ module.exports = { 'website/**', '**/__benchmarks__/**', '**/__tests__/**', - 'packages/jest-types/**/*', + '**/__typetests__/**', '.eslintplugin/**', ], rules: { diff --git a/jest.config.ts.mjs b/jest.config.ts.mjs index abc2822c2ca0..1bcbe631c425 100644 --- a/jest.config.ts.mjs +++ b/jest.config.ts.mjs @@ -29,6 +29,9 @@ export default { runner: 'jest-runner-tsd', testMatch: [ '**/__typetests__/**/*.test.ts', + '!**/packages/expect-utils/__typetests__/*.test.ts', + '!**/packages/jest/__typetests__/*.test.ts', + '!**/packages/jest-cli/__typetests__/*.test.ts', '!**/packages/jest-types/__typetests__/config.test.ts', ], }, diff --git a/packages/expect-utils/__typetests__/utils.test.ts b/packages/expect-utils/__typetests__/utils.test.ts index ed8fe71433fd..bd2d8a21d9db 100644 --- a/packages/expect-utils/__typetests__/utils.test.ts +++ b/packages/expect-utils/__typetests__/utils.test.ts @@ -5,34 +5,32 @@ * LICENSE file in the root directory of this source tree. */ -import {expectType} from 'tsd-lite'; +import {expect, test} from 'tstyche'; import {isA} from '@jest/expect-utils'; -// isA +test('isA', () => { + expect(isA('String', 'default')).type.toBeBoolean(); + expect(isA('Number', 123)).type.toBeBoolean(); -expectType(isA('String', 'default')); -expectType(isA('Number', 123)); + const sample = {} as unknown; -const sample = {} as unknown; + if (isA('String', sample)) { + expect(sample).type.toBeUnknown(); + } -expectType(sample); + if (isA('String', sample)) { + expect(sample).type.toBeString(); + } -if (isA('String', sample)) { - expectType(sample); -} + if (isA('Number', sample)) { + expect(sample).type.toBeNumber(); + } -if (isA('String', sample)) { - expectType(sample); -} + if (isA>('Map', sample)) { + expect(sample).type.toEqual>(); + } -if (isA('Number', sample)) { - expectType(sample); -} - -if (isA>('Map', sample)) { - expectType>(sample); -} - -if (isA>('Set', sample)) { - expectType>(sample); -} + if (isA>('Set', sample)) { + expect(sample).type.toEqual>(); + } +}); diff --git a/packages/expect-utils/package.json b/packages/expect-utils/package.json index 4b139017ca40..f5f2e7e558ad 100644 --- a/packages/expect-utils/package.json +++ b/packages/expect-utils/package.json @@ -22,10 +22,8 @@ "jest-get-type": "workspace:*" }, "devDependencies": { - "@tsd/typescript": "^5.0.4", "immutable": "^4.0.0", - "jest-matcher-utils": "workspace:*", - "tsd-lite": "^0.8.0" + "jest-matcher-utils": "workspace:*" }, "engines": { "node": "^16.10.0 || ^18.12.0 || >=20.0.0" diff --git a/packages/jest-cli/__typetests__/index.test.ts b/packages/jest-cli/__typetests__/jest-cli.test.ts similarity index 66% rename from packages/jest-cli/__typetests__/index.test.ts rename to packages/jest-cli/__typetests__/jest-cli.test.ts index f89e48a16669..a54f92f4c627 100644 --- a/packages/jest-cli/__typetests__/index.test.ts +++ b/packages/jest-cli/__typetests__/jest-cli.test.ts @@ -3,11 +3,12 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - * */ -import {expectType} from 'tsd-lite'; +import {expect, test} from 'tstyche'; import type {Options} from 'yargs'; import {yargsOptions} from 'jest-cli'; -expectType<{[key: string]: Options}>(yargsOptions); +test('yargsOptions', () => { + expect(yargsOptions).type.toEqual<{[key: string]: Options}>(); +}); diff --git a/packages/jest-cli/package.json b/packages/jest-cli/package.json index fbe97deee6df..285f0bd6e3b9 100644 --- a/packages/jest-cli/package.json +++ b/packages/jest-cli/package.json @@ -27,10 +27,8 @@ "yargs": "^17.3.1" }, "devDependencies": { - "@tsd/typescript": "^5.0.4", "@types/exit": "^0.1.30", - "@types/yargs": "^17.0.8", - "tsd-lite": "^0.8.0" + "@types/yargs": "^17.0.8" }, "peerDependencies": { "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" diff --git a/packages/jest/__typetests__/jest.test.ts b/packages/jest/__typetests__/jest.test.ts index 2cb13606c742..8eabd8961a40 100644 --- a/packages/jest/__typetests__/jest.test.ts +++ b/packages/jest/__typetests__/jest.test.ts @@ -5,10 +5,13 @@ * LICENSE file in the root directory of this source tree. */ -import {expectType} from 'tsd-lite'; -import type {Config as ConfigTypes} from '@jest/types'; +import {describe, expect, test} from 'tstyche'; import type {Config} from 'jest'; -declare const config: Config; +describe('Config', () => { + test('is a reexport of the `InitialOptions`', () => { + type InitialOptions = import('@jest/types').Config.InitialOptions; -expectType(config); + expect().type.toEqual(); + }); +}); diff --git a/packages/jest/package.json b/packages/jest/package.json index dda268c129b1..08d56e9d06de 100644 --- a/packages/jest/package.json +++ b/packages/jest/package.json @@ -20,10 +20,6 @@ "import-local": "^3.0.2", "jest-cli": "workspace:*" }, - "devDependencies": { - "@tsd/typescript": "^5.0.4", - "tsd-lite": "^0.8.0" - }, "peerDependencies": { "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" }, diff --git a/tstyche.config.json b/tstyche.config.json index 85b699bea9a9..69ff9c483816 100644 --- a/tstyche.config.json +++ b/tstyche.config.json @@ -1,3 +1,8 @@ { - "testFileMatch": ["**/packages/jest-types/__typetests__/config.test.ts"] + "testFileMatch": [ + "**/packages/expect-utils/__typetests__/*.test.ts", + "**/packages/jest/__typetests__/*.test.ts", + "**/packages/jest-cli/__typetests__/*.test.ts", + "**/packages/jest-types/__typetests__/config.test.ts" + ] } diff --git a/yarn.lock b/yarn.lock index 63d2c0c134d6..78ac27335f79 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2955,11 +2955,9 @@ __metadata: version: 0.0.0-use.local resolution: "@jest/expect-utils@workspace:packages/expect-utils" dependencies: - "@tsd/typescript": ^5.0.4 immutable: ^4.0.0 jest-get-type: "workspace:*" jest-matcher-utils: "workspace:*" - tsd-lite: ^0.8.0 languageName: unknown linkType: soft @@ -12869,7 +12867,6 @@ __metadata: "@jest/core": "workspace:*" "@jest/test-result": "workspace:*" "@jest/types": "workspace:*" - "@tsd/typescript": ^5.0.4 "@types/exit": ^0.1.30 "@types/yargs": ^17.0.8 chalk: ^4.0.0 @@ -12878,7 +12875,6 @@ __metadata: jest-config: "workspace:*" jest-util: "workspace:*" jest-validate: "workspace:*" - tsd-lite: ^0.8.0 yargs: ^17.3.1 peerDependencies: node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 @@ -13595,10 +13591,8 @@ __metadata: dependencies: "@jest/core": "workspace:*" "@jest/types": "workspace:*" - "@tsd/typescript": ^5.0.4 import-local: ^3.0.2 jest-cli: "workspace:*" - tsd-lite: ^0.8.0 peerDependencies: node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 peerDependenciesMeta: