From 55e8bddec61aea7a5839dff51f52938b58a3f29b Mon Sep 17 00:00:00 2001 From: Tony133 Date: Sat, 11 Apr 2026 18:02:21 +0200 Subject: [PATCH] refactor(types): migrate from tsd to tstyche --- package.json | 6 ++--- types/{index.test-d.ts => index.tst.ts} | 30 ++++++++++++------------- 2 files changed, 18 insertions(+), 18 deletions(-) rename types/{index.test-d.ts => index.tst.ts} (79%) diff --git a/package.json b/package.json index a8f4d6f..39e439e 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "lint": "eslint", "lint:fix": "eslint --fix", "test": "npm run test:unit && npm run test:typescript", - "test:typescript": "tsd", + "test:typescript": "tstyche", "test:unit": "c8 --100 node --test" }, "keywords": [ @@ -68,7 +68,7 @@ "fastify": "^5.0.0", "neostandard": "^0.13.0", "rimraf": "^6.0.1", - "tsd": "^0.33.0" + "tstyche": "^7.0.0" }, "dependencies": { "fastify-plugin": "^5.0.0", @@ -77,4 +77,4 @@ "publishConfig": { "access": "public" } -} +} \ No newline at end of file diff --git a/types/index.test-d.ts b/types/index.tst.ts similarity index 79% rename from types/index.test-d.ts rename to types/index.tst.ts index 44c44be..44cbc74 100644 --- a/types/index.test-d.ts +++ b/types/index.tst.ts @@ -1,6 +1,6 @@ import fastify, { FastifyInstance, FastifyReply, FastifyRequest, preHandlerHookHandler } from 'fastify' import fastifyAuth from '..' -import { expectType } from 'tsd' +import { expect } from 'tstyche' import { TypeBoxTypeProvider } from '@fastify/type-provider-typebox' import { JsonSchemaToTsProvider } from '@fastify/type-provider-json-schema-to-ts' @@ -11,33 +11,33 @@ type Done = (error?: Error) => void app.register(fastifyAuth).after((_err) => { app.auth([ (request, reply, done) => { - expectType(request) - expectType(reply) - expectType(done) + expect(request).type.toBe() + expect(reply).type.toBe() + expect(done).type.toBe() }, ], { relation: 'or' }) app.auth([ (request, reply, done) => { - expectType(request) - expectType(reply) - expectType(done) + expect(request).type.toBe() + expect(reply).type.toBe() + expect(done).type.toBe() }, ], { run: 'all' }) app.auth([ (request, reply, done) => { - expectType(request) - expectType(reply) - expectType(done) + expect(request).type.toBe() + expect(reply).type.toBe() + expect(done).type.toBe() }, ]) app.auth([ function () { - expectType(this) + expect(this).type.toBe() }, ]) const auth = app.auth([() => {}]) - expectType(auth) - app.get('/secret', { preHandler: auth }, () => {}) + expect(auth).type.toBe() + app.get('/secret', { preHandler: auth }, () => { }) app.get('/private', { preHandler: [auth] }, () => {}) }) @@ -102,7 +102,7 @@ async function usersController (fastify: FastifyInstance): Promise { async () => ({ success: true }) ) } -await usersController(app) +usersController(app) async function usersControllerV2 (fastify: FastifyInstance): Promise { fastify.patch<{ @@ -116,4 +116,4 @@ async function usersControllerV2 (fastify: FastifyInstance): Promise { async () => ({ success: true }) ) } -await usersControllerV2(app) +usersControllerV2(app)