|
2 | 2 | import { |
3 | 3 | ContextConfigDefault, |
4 | 4 | FastifyInstance, |
| 5 | + FastifyLoggerInstance, |
5 | 6 | FastifyReply, |
6 | 7 | FastifyRequest, |
| 8 | + FastifySchema, |
| 9 | + FastifyTypeProvider, |
| 10 | + FastifyTypeProviderDefault, |
7 | 11 | RawReplyDefaultExpression, |
8 | 12 | RawRequestDefaultExpression, |
9 | 13 | RawServerBase, |
10 | 14 | RawServerDefault, |
11 | | - RequestGenericInterface, |
12 | 15 | } from 'fastify' |
| 16 | +import { RouteGenericInterface } from 'fastify/types/route' |
| 17 | +import { FastifyRequestType, ResolveFastifyRequestType } from 'fastify/types/type-provider' |
13 | 18 | import { IncomingMessage, Server, ServerResponse } from 'http' |
14 | 19 | import { ReactElement } from 'react' |
15 | 20 | import { ViteDevServer } from 'vite' |
@@ -67,14 +72,31 @@ declare module 'fastify' { |
67 | 72 | RawServer extends RawServerBase = RawServerDefault, |
68 | 73 | RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>, |
69 | 74 | RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>, |
| 75 | + TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, |
70 | 76 | Props = any |
71 | 77 | > { |
72 | | - <RequestGeneric extends RequestGenericInterface = RequestGenericInterface, ContextConfig = ContextConfigDefault>( |
| 78 | + < |
| 79 | + RouteGeneric extends RouteGenericInterface = RouteGenericInterface, |
| 80 | + ContextConfig = ContextConfigDefault, |
| 81 | + SchemaCompiler = FastifySchema, |
| 82 | + RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>, |
| 83 | + Logger extends FastifyLoggerInstance = FastifyLoggerInstance |
| 84 | + >( |
73 | 85 | path: string, |
74 | | - opts: RouteShorthandOptions<RawServer, RawRequest, RawReply, RequestGeneric, ContextConfig> & { |
| 86 | + opts: RouteShorthandOptions< |
| 87 | + RawServer, |
| 88 | + RawRequest, |
| 89 | + RawReply, |
| 90 | + RouteGeneric, |
| 91 | + ContextConfig, |
| 92 | + SchemaCompiler, |
| 93 | + TypeProvider, |
| 94 | + RequestType, |
| 95 | + Logger |
| 96 | + > & { |
75 | 97 | render: string |
76 | 98 | }, // this creates an overload that only applies these different types if the handler is for rendering |
77 | 99 | handler: ServerRenderer<Props> |
78 | | - ): FastifyInstance<RawServer, RawRequest, RawReply> |
| 100 | + ): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider> |
79 | 101 | } |
80 | 102 | } |
0 commit comments