Skip to content

Commit 0394d2d

Browse files
committed
refactor(types): migrate from tsd to tstyche
1 parent bc0f340 commit 0394d2d

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"lint": "eslint",
2929
"lint:fix": "eslint --fix",
3030
"test": "npm run test:unit && npm run test:typescript",
31-
"test:typescript": "tsd",
31+
"test:typescript": "tstyche",
3232
"test:unit": "c8 --100 node --test"
3333
},
3434
"keywords": [
@@ -68,7 +68,7 @@
6868
"fastify": "^5.0.0",
6969
"neostandard": "^0.13.0",
7070
"rimraf": "^6.0.1",
71-
"tsd": "^0.33.0"
71+
"tstyche": "^7.0.0"
7272
},
7373
"dependencies": {
7474
"fastify-plugin": "^5.0.0",
@@ -77,4 +77,4 @@
7777
"publishConfig": {
7878
"access": "public"
7979
}
80-
}
80+
}
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fastify, { FastifyInstance, FastifyReply, FastifyRequest, preHandlerHookHandler } from 'fastify'
22
import fastifyAuth from '..'
3-
import { expectType } from 'tsd'
3+
import { expect } from 'tstyche'
44
import { TypeBoxTypeProvider } from '@fastify/type-provider-typebox'
55
import { JsonSchemaToTsProvider } from '@fastify/type-provider-json-schema-to-ts'
66

@@ -11,33 +11,33 @@ type Done = (error?: Error) => void
1111
app.register(fastifyAuth).after((_err) => {
1212
app.auth([
1313
(request, reply, done) => {
14-
expectType<FastifyRequest>(request)
15-
expectType<FastifyReply>(reply)
16-
expectType<Done>(done)
14+
expect(request).type.toBe<FastifyRequest>()
15+
expect(reply).type.toBe<FastifyReply>()
16+
expect(done).type.toBe<Done>()
1717
},
1818
], { relation: 'or' })
1919
app.auth([
2020
(request, reply, done) => {
21-
expectType<FastifyRequest>(request)
22-
expectType<FastifyReply>(reply)
23-
expectType<Done>(done)
21+
expect(request).type.toBe<FastifyRequest>()
22+
expect(reply).type.toBe<FastifyReply>()
23+
expect(done).type.toBe<Done>()
2424
},
2525
], { run: 'all' })
2626
app.auth([
2727
(request, reply, done) => {
28-
expectType<FastifyRequest>(request)
29-
expectType<FastifyReply>(reply)
30-
expectType<Done>(done)
28+
expect(request).type.toBe<FastifyRequest>()
29+
expect(reply).type.toBe<FastifyReply>()
30+
expect(done).type.toBe<Done>()
3131
},
3232
])
3333
app.auth([
3434
function () {
35-
expectType<FastifyInstance>(this)
35+
expect(this).type.toBe<FastifyInstance>()
3636
},
3737
])
3838
const auth = app.auth([() => {}])
39-
expectType<preHandlerHookHandler>(auth)
40-
app.get('/secret', { preHandler: auth }, () => {})
39+
expect(auth).type.toBe<preHandlerHookHandler>()
40+
app.get('/secret', { preHandler: auth }, () => { })
4141
app.get('/private', { preHandler: [auth] }, () => {})
4242
})
4343

@@ -102,7 +102,7 @@ async function usersController (fastify: FastifyInstance): Promise<void> {
102102
async () => ({ success: true })
103103
)
104104
}
105-
await usersController(app)
105+
usersController(app)
106106

107107
async function usersControllerV2 (fastify: FastifyInstance): Promise<void> {
108108
fastify.patch<{
@@ -116,4 +116,4 @@ async function usersControllerV2 (fastify: FastifyInstance): Promise<void> {
116116
async () => ({ success: true })
117117
)
118118
}
119-
await usersControllerV2(app)
119+
usersControllerV2(app)

0 commit comments

Comments
 (0)