1- import { expectType , expectAssignable } from 'tsd '
1+ import { expect } from 'tstyche '
22import fastify , {
33 FastifyRequest ,
44 FastifyReply ,
@@ -14,36 +14,36 @@ const app = fastify()
1414// validation ok
1515app . register ( fastifyBasicAuth , {
1616 validate : async function validatePromise ( username , password , req , reply ) {
17- expectType < string > ( username )
18- expectType < string > ( password )
19- expectType < FastifyRequest > ( req )
20- expectType < FastifyReply > ( reply )
21- expectType < FastifyInstance > ( this )
17+ expect ( username ) . type . toBe < string > ( )
18+ expect ( password ) . type . toBe < string > ( )
19+ expect ( req ) . type . toBe < FastifyRequest > ( )
20+ expect ( reply ) . type . toBe < FastifyReply > ( )
21+ expect ( this ) . type . toBe < FastifyInstance > ( )
2222 } ,
2323 header : 'x-forwarded-authorization'
2424} )
2525
2626// validation failure
2727app . register ( fastifyBasicAuth , {
2828 validate : async function validatePromise ( username , password , req , reply ) {
29- expectType < string > ( username )
30- expectType < string > ( password )
31- expectType < FastifyRequest > ( req )
32- expectType < FastifyReply > ( reply )
33- expectType < FastifyInstance > ( this )
29+ expect ( username ) . type . toBe < string > ( )
30+ expect ( password ) . type . toBe < string > ( )
31+ expect ( req ) . type . toBe < FastifyRequest > ( )
32+ expect ( reply ) . type . toBe < FastifyReply > ( )
33+ expect ( this ) . type . toBe < FastifyInstance > ( )
3434 return new Error ( 'unauthorized' )
3535 } ,
3636 header : 'x-forwarded-authorization'
3737} )
3838
3939app . register ( fastifyBasicAuth , {
4040 validate : function validateCallback ( username , password , req , reply , done ) {
41- expectType < string > ( username )
42- expectType < string > ( password )
43- expectType < FastifyRequest > ( req )
44- expectType < FastifyReply > ( reply )
45- expectAssignable < ( err ?: Error ) => void > ( done )
46- expectType < FastifyInstance > ( this )
41+ expect ( username ) . type . toBe < string > ( )
42+ expect ( password ) . type . toBe < string > ( )
43+ expect ( req ) . type . toBe < FastifyRequest > ( )
44+ expect ( reply ) . type . toBe < FastifyReply > ( )
45+ expect ( done ) . type . toBeAssignableTo < ( err ?: Error ) => void > ( )
46+ expect ( this ) . type . toBe < FastifyInstance > ( )
4747 }
4848} )
4949
@@ -98,6 +98,6 @@ app.register(fastifyBasicAuth, {
9898 utf8 : undefined
9999} )
100100
101- expectAssignable < onRequestHookHandler > ( app . basicAuth )
102- expectAssignable < preValidationHookHandler > ( app . basicAuth )
103- expectAssignable < preHandlerHookHandler > ( app . basicAuth )
101+ expect ( app . basicAuth ) . type . toBeAssignableTo < onRequestHookHandler > ( )
102+ expect ( app . basicAuth ) . type . toBeAssignableTo < preValidationHookHandler > ( )
103+ expect ( app . basicAuth ) . type . toBeAssignableTo < preHandlerHookHandler > ( )
0 commit comments