From 9dba69c8196e8ae73c0c179e32d0593e438d9caa Mon Sep 17 00:00:00 2001 From: Puppo Date: Sun, 10 May 2026 19:07:49 +0000 Subject: [PATCH 1/3] refactor(types): migrate from tsd to tstyche --- package.json | 4 +- types/{index.test-d.ts => index.tst.ts} | 64 +++++++++++++------------ 2 files changed, 35 insertions(+), 33 deletions(-) rename types/{index.test-d.ts => index.tst.ts} (59%) diff --git a/package.json b/package.json index 7b76cdb..473258d 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "lint:fix": "eslint --fix", "unit": "c8 --100 node --test", "test": "npm run unit && npm run test:typescript", - "test:typescript": "tsd" + "test:typescript": "tstyche" }, "repository": { "type": "git", @@ -58,7 +58,7 @@ "fastify": "^5.0.0", "neostandard": "^0.13.0", "sanitize-filename": "^1.6.3", - "tsd": "^0.33.0" + "tstyche": "^7.1.0" }, "dependencies": { "fast-json-stringify": "^6.0.0" diff --git a/types/index.test-d.ts b/types/index.tst.ts similarity index 59% rename from types/index.test-d.ts rename to types/index.tst.ts index 018759a..421913e 100644 --- a/types/index.test-d.ts +++ b/types/index.tst.ts @@ -1,4 +1,4 @@ -import { expectAssignable, expectError, expectType } from 'tsd' +import { expect } from 'tstyche' import SerializerSelector, { RouteDefinition, Serializer, @@ -14,12 +14,12 @@ import SerializerSelector, { { const compiler = SerializerSelector() - expectType(compiler) + expect(compiler).type.toBe() } { const compiler = SerializerSelectorNamed() - expectType(compiler) + expect(compiler).type.toBe() } { @@ -34,13 +34,13 @@ import SerializerSelector, { const externalSchemas1 = {} const factory = SerializerSelector() - expectType(factory) + expect(factory).type.toBe() const compiler = factory(externalSchemas1, {}) - expectType(compiler) + expect(compiler).type.toBe() const serializeFunc = compiler({ schema: sampleSchema, method: '', url: '', httpStatus: '' }) - expectType(serializeFunc) + expect(serializeFunc).type.toBe() - expectType(serializeFunc({ name: 'hello' })) + expect(serializeFunc({ name: 'hello' })).type.toBe() } /** @@ -50,20 +50,20 @@ import SerializerSelector, { const reader = StandaloneSerializer({ readMode: true, restoreFunction: (route: RouteDefinition) => { - expectAssignable(route) + expect(route).type.toBeAssignableTo() return {} as Serializer }, }) -expectType(reader) +expect(reader).type.toBe() const writer = StandaloneSerializer({ readMode: false, storeFunction: (route: RouteDefinition, code: string) => { - expectAssignable(route) - expectAssignable(code) + expect(route).type.toBeAssignableTo() + expect(code).type.toBeAssignableTo() }, }) -expectType(writer) +expect(writer).type.toBe() { const base = { @@ -100,43 +100,45 @@ expectType(writer) [refSchema.$id]: refSchema } - expectError(StandaloneSerializer({ + expect(StandaloneSerializer).type.not.toBeCallableWith({ readMode: true, storeFunction () { } - })) - expectError(StandaloneSerializer({ + }) + + expect(StandaloneSerializer).type.not.toBeCallableWith({ readMode: false, restoreFunction () {} - })) - expectError(StandaloneSerializer({ + }) + + expect(StandaloneSerializer).type.not.toBeCallableWith({ restoreFunction () {} - })) + }) - expectType(StandaloneSerializer({ + expect(StandaloneSerializer({ storeFunction (routeOpts, schemaSerializerCode) { - expectType(routeOpts) - expectType(schemaSerializerCode) + expect(routeOpts).type.toBe() + expect(schemaSerializerCode).type.toBe() } - })) + })).type.toBe() - expectType(StandaloneSerializer({ + expect(StandaloneSerializer({ readMode: true, restoreFunction (routeOpts) { - expectType(routeOpts) + expect(routeOpts).type.toBe() return {} as Serializer } - })) + })).type.toBe() const factory = StandaloneSerializer({ readMode: false, storeFunction (routeOpts, schemaSerializerCode) { - expectType(routeOpts) - expectType(schemaSerializerCode) + expect(routeOpts).type.toBe() + expect(schemaSerializerCode).type.toBe() } }) - expectType(factory) + expect(factory).type.toBe() const compiler = factory(schemaMap) - expectType(compiler) - expectType(compiler(endpointSchema)) -} + expect(compiler).type.toBe() + expect(compiler(endpointSchema)).type.toBe() +} \ No newline at end of file From 77557d9a5c78d9a2334343ebd1f88264b2308bc2 Mon Sep 17 00:00:00 2001 From: Puppo Date: Mon, 11 May 2026 18:23:18 +0000 Subject: [PATCH 2/3] style: add trailing newline to types/index.tst.ts --- types/index.tst.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/index.tst.ts b/types/index.tst.ts index 421913e..2e4b392 100644 --- a/types/index.tst.ts +++ b/types/index.tst.ts @@ -141,4 +141,4 @@ expect(writer).type.toBe() const compiler = factory(schemaMap) expect(compiler).type.toBe() expect(compiler(endpointSchema)).type.toBe() -} \ No newline at end of file +} From b5b7c02a311288b6f4faf143540081f6841790c5 Mon Sep 17 00:00:00 2001 From: Luca Del Puppo Date: Tue, 12 May 2026 16:14:45 +0200 Subject: [PATCH 3/3] refactor(types): simplify type assertions in StandaloneSerializer functions --- types/index.tst.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/types/index.tst.ts b/types/index.tst.ts index 2e4b392..4b0b6aa 100644 --- a/types/index.tst.ts +++ b/types/index.tst.ts @@ -49,8 +49,8 @@ import SerializerSelector, { const reader = StandaloneSerializer({ readMode: true, - restoreFunction: (route: RouteDefinition) => { - expect(route).type.toBeAssignableTo() + restoreFunction: (route) => { + expect(route).type.toBe() return {} as Serializer }, }) @@ -58,9 +58,9 @@ expect(reader).type.toBe() const writer = StandaloneSerializer({ readMode: false, - storeFunction: (route: RouteDefinition, code: string) => { - expect(route).type.toBeAssignableTo() - expect(code).type.toBeAssignableTo() + storeFunction: (route, code) => { + expect(route).type.toBe() + expect(code).type.toBe() }, }) expect(writer).type.toBe()