Skip to content

Commit 7e37c7e

Browse files
committed
refactor(types): migrate from tsd to tstyche
1 parent 792d2f4 commit 7e37c7e

4 files changed

Lines changed: 26 additions & 28 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"lint:fix": "eslint --fix",
1111
"test": "npm run test:unit && npm run test:typescript",
1212
"test:unit": "c8 --100 node --test",
13-
"test:typescript": "tsd"
13+
"test:typescript": "tstyche"
1414
},
1515
"keywords": [
1616
"fastify",
@@ -67,7 +67,7 @@
6767
"helmet": "^8.0.0",
6868
"neostandard": "^0.13.0",
6969
"serve-static": "^2.2.0",
70-
"tsd": "^0.33.0"
70+
"tstyche": "^7.0.0"
7171
},
7272
"dependencies": {
7373
"@fastify/error": "^4.0.0",

types/index.d.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ declare namespace fastifyMiddie {
1717
hook?: 'onRequest' | 'preParsing' | 'preValidation' | 'preHandler' | 'preSerialization' | 'onSend' | 'onResponse' | 'onTimeout' | 'onError';
1818
}
1919

20-
/**
21-
* @deprecated Use FastifyMiddieOptions instead
22-
*/
23-
export type MiddiePluginOptions = FastifyMiddieOptions
24-
2520
export interface IncomingMessageExtended {
2621
body?: any;
2722
query?: any;

types/index.test-d.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

types/index.tst.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import fastify from 'fastify'
2+
import middiePlugin, {
3+
FastifyMiddieOptions,
4+
IncomingMessageExtended
5+
} from '.'
6+
import { expect } from 'tstyche'
7+
8+
const app = fastify()
9+
app.register(middiePlugin)
10+
11+
expect({}).type.toBeAssignableTo<FastifyMiddieOptions>()
12+
13+
expect({ body: { foo: 'bar' }, query: { bar: 'foo' } }).type.toBeAssignableTo<IncomingMessageExtended>()
14+
expect({}).type.toBeAssignableTo<IncomingMessageExtended>()
15+
16+
app.use('/', (_req, _res, next) => {
17+
expect<any>().type.toBeAssignableTo<IncomingMessageExtended['body']>()
18+
expect<any>().type.toBeAssignableTo<IncomingMessageExtended['query']>()
19+
next()
20+
})
21+
22+
expect(app.register).type.not.toBeCallableWith(middiePlugin, {
23+
invalidOption: true
24+
})

0 commit comments

Comments
 (0)