-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
i cant got it logged in! #5704
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the issue has not already been raised
Issue
server.get<{
Querystring: IQuerystring,
Headers: IHeaders,
Reply: IReply
}>('/auth', async (request, reply) => {
const { username, password } = request.query
const customerHeader = request.headers['h-Custom']
// do something with request data
// chaining .statusCode/.code calls with .send allows type narrowing. For example:
// this works
reply.code(200).send({ success: true });
// but this gives a type error
reply.code(200).send('uh-oh');
// it even works for wildcards
reply.code(404).send({ error: 'Not found' });
return `logged in!`
})
my error:
[{
"resource": "/home/raqeb/Desktop/practice/fastify/index.ts",
"owner": "typescript",
"code": "2769",
"severity": 8,
"message": "No overload matches this call.\n Overload 1 of 3, '(path: string, handler: RouteHandlerMethod<Server<typeof IncomingMessage, typeof ServerResponse>, IncomingMessage, ServerResponse, ... 4 more ..., FastifyBaseLogger>): FastifyInstance<...>', gave the following error.\n Argument of type '(this: FastifyInstance<...>, request: FastifyRequest<{ Querystring: IQuerystring; Headers: IHeaders; Reply: IReply; }, Server<typeof IncomingMessage, typeof ServerResponse>, ... 5 more ..., ResolveFastifyRequestType<...>>, reply: FastifyReply<...>) => Promise<...>' is not assignable to parameter of type 'RouteHandlerMethod<Server<typeof IncomingMessage, typeof ServerResponse>, IncomingMessage, ServerResponse, ... 4 more ..., FastifyBaseLogger>'.\n Type 'Promise' is not assignable to type 'void | IReply | Promise<void | IReply>'.\n Type 'Promise' is not assignable to type 'Promise<void | IReply>'.\n Type 'string' is not assignable to type 'void | IReply'.\n Overload 2 of 3, '(path: string, opts: RouteShorthandOptionsWithHandler<Server<typeof IncomingMessage, typeof ServerResponse>, IncomingMessage, ServerResponse, ... 4 more ..., FastifyBaseLogger>): FastifyInstance<...>', gave the following error.\n Argument of type '(this: FastifyInstance<...>, request: FastifyRequest<{ Querystring: IQuerystring; Headers: IHeaders; Reply: IReply; }, Server<typeof IncomingMessage, typeof ServerResponse>, ... 5 more ..., ResolveFastifyRequestType<...>>, reply: FastifyReply<...>) => Promise<...>' is not assignable to parameter of type 'RouteShorthandOptionsWithHandler<Server<typeof IncomingMessage, typeof ServerResponse>, IncomingMessage, ServerResponse, ... 4 more ..., FastifyBaseLogger>'.",
"source": "ts",
"startLineNumber": 37,
"startColumn": 15,
"endLineNumber": 37,
"endColumn": 42
}],
Argument of type 'string' is not assignable to parameter of type '{ success: boolean; }'.