From 0affbde1d8a06150c4d840e936f285753de0b8b2 Mon Sep 17 00:00:00 2001 From: Tom Mrazauskas Date: Thu, 9 Nov 2023 16:15:50 +0200 Subject: [PATCH 1/5] chore: migrate `Config` type test to TSTyche --- .github/workflows/nodejs.yml | 2 +- jest.config.ts.mjs | 5 +- package.json | 3 +- .../jest-types/__typetests__/config.test.ts | 211 +++++++++--------- tstyche.config.json | 3 + yarn.lock | 15 ++ 6 files changed, 136 insertions(+), 103 deletions(-) create mode 100644 tstyche.config.json diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index a79002a1351a..baffc525b028 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -48,7 +48,7 @@ jobs: - name: ts integration run: yarn test-ts --selectProjects ts-integration - name: type tests - run: yarn test-ts --selectProjects type-tests + run: yarn tstyche --target 5.0,latest && yarn test-ts --selectProjects type-tests - name: verify TypeScript@5.0 compatibility run: yarn verify-old-ts - name: run ESLint with type info diff --git a/jest.config.ts.mjs b/jest.config.ts.mjs index 1bd388dc9c24..abc2822c2ca0 100644 --- a/jest.config.ts.mjs +++ b/jest.config.ts.mjs @@ -27,7 +27,10 @@ export default { modulePathIgnorePatterns: baseConfig.modulePathIgnorePatterns, roots: ['/packages'], runner: 'jest-runner-tsd', - testMatch: ['**/__typetests__/**/*.test.ts'], + testMatch: [ + '**/__typetests__/**/*.test.ts', + '!**/packages/jest-types/__typetests__/config.test.ts', + ], }, ], reporters: ['default', 'github-actions'], diff --git a/package.json b/package.json index f2a1b3f2a052..8369e91d83fd 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "strip-json-comments": "^3.1.1", "tempy": "^1.0.0", "ts-node": "^10.5.0", + "tstyche": "^1.0.0-beta.1", "typescript": "^5.0.4", "webpack": "^5.68.0", "webpack-node-externals": "^3.0.0", @@ -109,7 +110,7 @@ "test-ci-partial:parallel": "yarn jest --color --config jest.config.ci.mjs", "test-leak": "yarn jest -i --detectLeaks --color jest-mock jest-diff jest-repl pretty-format", "test-ts": "yarn jest --config jest.config.ts.mjs", - "test-types": "yarn test-ts --selectProjects type-tests", + "test-types": "yarn tstyche && yarn test-ts --selectProjects type-tests", "test": "yarn lint && yarn jest", "typecheck": "yarn typecheck:examples && yarn typecheck:tests", "typecheck:examples": "tsc -p examples/angular --noEmit && tsc -p examples/expect-extend --noEmit && tsc -p examples/typescript --noEmit", diff --git a/packages/jest-types/__typetests__/config.test.ts b/packages/jest-types/__typetests__/config.test.ts index b3516824be64..788bb12ed75d 100644 --- a/packages/jest-types/__typetests__/config.test.ts +++ b/packages/jest-types/__typetests__/config.test.ts @@ -5,115 +5,126 @@ * LICENSE file in the root directory of this source tree. */ -import {expectAssignable, expectNotAssignable} from 'tsd-lite'; -import type {Config} from '@jest/types'; +import {describe, expect, test} from 'tstyche'; +import type {Config} from 'jest'; -expectAssignable({}); +const config: Config = {}; -expectAssignable({ - coverageThreshold: { - './src/api/very-important-module.js': { - branches: 100, - functions: 100, - lines: 100, - statements: 100, - }, - './src/components/': { - branches: 40, - statements: 40, - }, - './src/reducers/**/*.js': { - statements: 90, - }, - global: { - branches: 50, - functions: 50, - lines: 50, - statements: 50, - }, - }, - projects: [ - // projects can be globs or objects - './src/**', - { - displayName: 'A Project', - rootDir: './src/components', - }, - ], -}); +describe('Config', () => { + test('coverageThreshold', () => { + expect(config).type.toBeAssignable({ + coverageThreshold: { + './src/api/very-important-module.js': { + branches: 100, + functions: 100, + lines: 100, + statements: 100, + }, + './src/components/': { + branches: 40, + statements: 40, + }, + './src/reducers/**/*.js': { + statements: 90, + }, + global: { + branches: 50, + functions: 50, + lines: 50, + statements: 50, + }, + }, + }); + }); -const doNotFake: Array = [ - 'Date', - 'hrtime', - 'nextTick', - 'performance', - 'queueMicrotask', - 'requestAnimationFrame', - 'cancelAnimationFrame', - 'requestIdleCallback', - 'cancelIdleCallback', - 'setImmediate', - 'clearImmediate', - 'setInterval', - 'clearInterval', - 'setTimeout', - 'clearTimeout', -]; + test('fakeTimers', () => { + const doNotFake = [ + 'Date' as const, + 'hrtime' as const, + 'nextTick' as const, + 'performance' as const, + 'queueMicrotask' as const, + 'requestAnimationFrame' as const, + 'cancelAnimationFrame' as const, + 'requestIdleCallback' as const, + 'cancelIdleCallback' as const, + 'setImmediate' as const, + 'clearImmediate' as const, + 'setInterval' as const, + 'clearInterval' as const, + 'setTimeout' as const, + 'clearTimeout' as const, + ]; -expectAssignable({ - fakeTimers: { - advanceTimers: true, - doNotFake, - enableGlobally: true, - now: 1_483_228_800_000, - timerLimit: 1000, - }, -}); + expect(config).type.toBeAssignable({ + fakeTimers: { + advanceTimers: true, + doNotFake, + enableGlobally: true, + now: 1_483_228_800_000, + timerLimit: 1000, + }, + }); -expectAssignable({ - fakeTimers: { - advanceTimers: 40, - now: Date.now(), - }, -}); + expect(config).type.toBeAssignable({ + fakeTimers: { + advanceTimers: 40, + now: Date.now(), + }, + }); -expectNotAssignable({ - fakeTimers: { - now: new Date(), - }, -}); + expect(config).type.not.toBeAssignable({ + fakeTimers: { + now: new Date(), + }, + }); -expectAssignable({ - fakeTimers: { - enableGlobally: true, - legacyFakeTimers: true as const, - }, -}); + expect(config).type.toBeAssignable({ + fakeTimers: { + enableGlobally: true, + legacyFakeTimers: true as const, + }, + }); -expectNotAssignable({ - fakeTimers: { - advanceTimers: true, - legacyFakeTimers: true as const, - }, -}); + expect(config).type.not.toBeAssignable({ + fakeTimers: { + advanceTimers: true, + legacyFakeTimers: true as const, + }, + }); -expectNotAssignable({ - fakeTimers: { - doNotFake, - legacyFakeTimers: true as const, - }, -}); + expect(config).type.not.toBeAssignable({ + fakeTimers: { + doNotFake, + legacyFakeTimers: true as const, + }, + }); -expectNotAssignable({ - fakeTimers: { - legacyFakeTimers: true as const, - now: 1_483_228_800_000, - }, -}); + expect(config).type.not.toBeAssignable({ + fakeTimers: { + legacyFakeTimers: true as const, + now: 1_483_228_800_000, + }, + }); + + expect(config).type.not.toBeAssignable({ + fakeTimers: { + legacyFakeTimers: true as const, + timerLimit: 1000, + }, + }); + }); -expectNotAssignable({ - fakeTimers: { - legacyFakeTimers: true as const, - timerLimit: 1000, - }, + test('projects', () => { + expect(config).type.toBeAssignable({ + projects: [ + // projects can be globs or objects + './src/**', + { + displayName: 'A Project', + rootDir: './src/components', + }, + ], + }); + }); }); diff --git a/tstyche.config.json b/tstyche.config.json new file mode 100644 index 000000000000..85b699bea9a9 --- /dev/null +++ b/tstyche.config.json @@ -0,0 +1,3 @@ +{ + "testFileMatch": ["**/packages/jest-types/__typetests__/config.test.ts"] +} diff --git a/yarn.lock b/yarn.lock index 0e59bb708bdd..626f4e70f52d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3038,6 +3038,7 @@ __metadata: strip-json-comments: ^3.1.1 tempy: ^1.0.0 ts-node: ^10.5.0 + tstyche: ^1.0.0-beta.1 typescript: ^5.0.4 webpack: ^5.68.0 webpack-node-externals: ^3.0.0 @@ -21028,6 +21029,20 @@ __metadata: languageName: node linkType: hard +"tstyche@npm:^1.0.0-beta.1": + version: 1.0.0-beta.1 + resolution: "tstyche@npm:1.0.0-beta.1" + peerDependencies: + typescript: 4.x || 5.x + peerDependenciesMeta: + typescript: + optional: true + bin: + tstyche: build/bin.js + checksum: 7a1763dc053159920308158f35e4497f256abd5d322e9ddb7dfd81fdd7ca499b189e4f1022f34629793d0b972bca58e78b84c139685f6024a290ab437b3fd862 + languageName: node + linkType: hard + "tsutils@npm:^3.21.0": version: 3.21.0 resolution: "tsutils@npm:3.21.0" From c6764f3ef55bdbd0fb8dcc5d6625d7f66898e599 Mon Sep 17 00:00:00 2001 From: Tom Mrazauskas Date: Sun, 12 Nov 2023 14:10:57 +0200 Subject: [PATCH 2/5] bump 'tstyche' --- package.json | 2 +- yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 8369e91d83fd..1697d3a1aede 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "strip-json-comments": "^3.1.1", "tempy": "^1.0.0", "ts-node": "^10.5.0", - "tstyche": "^1.0.0-beta.1", + "tstyche": "^1.0.0-beta.2", "typescript": "^5.0.4", "webpack": "^5.68.0", "webpack-node-externals": "^3.0.0", diff --git a/yarn.lock b/yarn.lock index fa579dd392ea..08a4795da4bf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3038,7 +3038,7 @@ __metadata: strip-json-comments: ^3.1.1 tempy: ^1.0.0 ts-node: ^10.5.0 - tstyche: ^1.0.0-beta.1 + tstyche: ^1.0.0-beta.2 typescript: ^5.0.4 webpack: ^5.68.0 webpack-node-externals: ^3.0.0 @@ -21036,9 +21036,9 @@ __metadata: languageName: node linkType: hard -"tstyche@npm:^1.0.0-beta.1": - version: 1.0.0-beta.1 - resolution: "tstyche@npm:1.0.0-beta.1" +"tstyche@npm:^1.0.0-beta.2": + version: 1.0.0-beta.2 + resolution: "tstyche@npm:1.0.0-beta.2" peerDependencies: typescript: 4.x || 5.x peerDependenciesMeta: @@ -21046,7 +21046,7 @@ __metadata: optional: true bin: tstyche: build/bin.js - checksum: 7a1763dc053159920308158f35e4497f256abd5d322e9ddb7dfd81fdd7ca499b189e4f1022f34629793d0b972bca58e78b84c139685f6024a290ab437b3fd862 + checksum: f8c5f8f1c7f7fb73d475938ee0a85f71281240044a56894c72c3587c68a84f96d6feb811b2115b644775188ad110fbd562f0c9c81fbb82a34ed33fffabf4b640 languageName: node linkType: hard From b4c152dfa169bdd31714f795ca3e174bf9ab78d6 Mon Sep 17 00:00:00 2001 From: Tom Mrazauskas Date: Mon, 13 Nov 2023 13:18:02 +0200 Subject: [PATCH 3/5] bump 'tstyche' --- package.json | 2 +- yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 1697d3a1aede..05ed72ab4595 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "strip-json-comments": "^3.1.1", "tempy": "^1.0.0", "ts-node": "^10.5.0", - "tstyche": "^1.0.0-beta.2", + "tstyche": "^1.0.0-beta.3", "typescript": "^5.0.4", "webpack": "^5.68.0", "webpack-node-externals": "^3.0.0", diff --git a/yarn.lock b/yarn.lock index 08a4795da4bf..89e99e3b347a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3038,7 +3038,7 @@ __metadata: strip-json-comments: ^3.1.1 tempy: ^1.0.0 ts-node: ^10.5.0 - tstyche: ^1.0.0-beta.2 + tstyche: ^1.0.0-beta.3 typescript: ^5.0.4 webpack: ^5.68.0 webpack-node-externals: ^3.0.0 @@ -21036,9 +21036,9 @@ __metadata: languageName: node linkType: hard -"tstyche@npm:^1.0.0-beta.2": - version: 1.0.0-beta.2 - resolution: "tstyche@npm:1.0.0-beta.2" +"tstyche@npm:^1.0.0-beta.3": + version: 1.0.0-beta.3 + resolution: "tstyche@npm:1.0.0-beta.3" peerDependencies: typescript: 4.x || 5.x peerDependenciesMeta: @@ -21046,7 +21046,7 @@ __metadata: optional: true bin: tstyche: build/bin.js - checksum: f8c5f8f1c7f7fb73d475938ee0a85f71281240044a56894c72c3587c68a84f96d6feb811b2115b644775188ad110fbd562f0c9c81fbb82a34ed33fffabf4b640 + checksum: 81fb7e6819eab6ceea238870cdeab70d76af1894415bce873e08834a9b12a24e96a2c025fd2af62e3f3214233cf6b599c0f52b1afce3bdca67e4a8d52e87e213 languageName: node linkType: hard From ae6e67bdbda2b5b2c5eb1ca2182746427ed83ef5 Mon Sep 17 00:00:00 2001 From: Tom Mrazauskas Date: Fri, 24 Nov 2023 13:39:30 +0200 Subject: [PATCH 4/5] bump TSTyche --- package.json | 2 +- yarn.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 8be1471ea50e..418bcc0ee1f7 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "strip-json-comments": "^3.1.1", "tempy": "^1.0.0", "ts-node": "^10.5.0", - "tstyche": "^1.0.0-beta.3", + "tstyche": "^1.0.0-beta.4", "typescript": "^5.0.4", "webpack": "^5.68.0", "webpack-node-externals": "^3.0.0", diff --git a/yarn.lock b/yarn.lock index 55374c8b9787..502f6289513b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3038,7 +3038,7 @@ __metadata: strip-json-comments: ^3.1.1 tempy: ^1.0.0 ts-node: ^10.5.0 - tstyche: ^1.0.0-beta.3 + tstyche: ^1.0.0-beta.4 typescript: ^5.0.4 webpack: ^5.68.0 webpack-node-externals: ^3.0.0 @@ -21036,17 +21036,17 @@ __metadata: languageName: node linkType: hard -"tstyche@npm:^1.0.0-beta.3": - version: 1.0.0-beta.3 - resolution: "tstyche@npm:1.0.0-beta.3" +"tstyche@npm:^1.0.0-beta.4": + version: 1.0.0-beta.4 + resolution: "tstyche@npm:1.0.0-beta.4" peerDependencies: typescript: 4.x || 5.x peerDependenciesMeta: typescript: optional: true bin: - tstyche: build/bin.js - checksum: 81fb7e6819eab6ceea238870cdeab70d76af1894415bce873e08834a9b12a24e96a2c025fd2af62e3f3214233cf6b599c0f52b1afce3bdca67e4a8d52e87e213 + tstyche: ./build/bin.js + checksum: af000e69722907c773dd8e5295f4e9ed8cb94ae7e7abe6363eee6a0a463b0dbde2a26ad76e5a7d75cb513b911e8f58e5a50238182fcacabc93c70f8fb99b7bc2 languageName: node linkType: hard From 14d452b4d54587fc0c95cb6742b158f52e6e687e Mon Sep 17 00:00:00 2001 From: Tom Mrazauskas Date: Mon, 25 Dec 2023 15:42:03 +0200 Subject: [PATCH 5/5] bump TSTyche --- package.json | 2 +- yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index a8375c229a26..6baaf46987cc 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "strip-json-comments": "^3.1.1", "tempy": "^1.0.0", "ts-node": "^10.5.0", - "tstyche": "^1.0.0-beta.4", + "tstyche": "^1.0.0-beta.6", "typescript": "^5.0.4", "webpack": "^5.68.0", "webpack-node-externals": "^3.0.0", diff --git a/yarn.lock b/yarn.lock index 03679f05358c..a08ac3efda97 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3060,7 +3060,7 @@ __metadata: strip-json-comments: ^3.1.1 tempy: ^1.0.0 ts-node: ^10.5.0 - tstyche: ^1.0.0-beta.4 + tstyche: ^1.0.0-beta.6 typescript: ^5.0.4 webpack: ^5.68.0 webpack-node-externals: ^3.0.0 @@ -21110,9 +21110,9 @@ __metadata: languageName: node linkType: hard -"tstyche@npm:^1.0.0-beta.4": - version: 1.0.0-beta.4 - resolution: "tstyche@npm:1.0.0-beta.4" +"tstyche@npm:^1.0.0-beta.6": + version: 1.0.0-beta.6 + resolution: "tstyche@npm:1.0.0-beta.6" peerDependencies: typescript: 4.x || 5.x peerDependenciesMeta: @@ -21120,7 +21120,7 @@ __metadata: optional: true bin: tstyche: ./build/bin.js - checksum: af000e69722907c773dd8e5295f4e9ed8cb94ae7e7abe6363eee6a0a463b0dbde2a26ad76e5a7d75cb513b911e8f58e5a50238182fcacabc93c70f8fb99b7bc2 + checksum: 197ef69d05b8a82f5d0d4a618ed36102d906badb537712d4399387f2ed822b076d37d8a4c2b8e2d13582fb733d0737794b6789a4635bde23bd41f520ddb8c337 languageName: node linkType: hard