From 9a73cde0d26ab5afb11f168777f374624c98c0ae Mon Sep 17 00:00:00 2001 From: flakey5 <73616808+flakey5@users.noreply.github.com> Date: Fri, 19 Jan 2024 12:52:41 -0800 Subject: [PATCH] types: replace declaration merging with mixin types Background: https://github.com/fastify/fastify/issues/5061 --- types/index.d.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index 963bae0e..e8ba8ef7 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -2,18 +2,16 @@ // Leo /// -import { FastifyPluginAsync, FastifyRequest, RouteOptions } from 'fastify' +import { FastifyPluginAsync, FastifyRequest, RouteOptions, FastifyReply } from 'fastify' import { Stats } from 'fs' -declare module 'fastify' { - interface FastifyReply { - sendFile(filename: string, rootPath?: string): FastifyReply; - sendFile(filename: string, options?: fastifyStatic.SendOptions): FastifyReply; - sendFile(filename: string, rootPath?: string, options?: fastifyStatic.SendOptions): FastifyReply; - download(filepath: string, options?: fastifyStatic.SendOptions): FastifyReply; - download(filepath: string, filename?: string): FastifyReply; - download(filepath: string, filename?: string, options?: fastifyStatic.SendOptions): FastifyReply; - } +export class StaticReplyMixin { + sendFile(filename: string, rootPath?: string): FastifyReply; + sendFile(filename: string, options?: fastifyStatic.SendOptions): FastifyReply; + sendFile(filename: string, rootPath?: string, options?: fastifyStatic.SendOptions): FastifyReply; + download(filepath: string, options?: fastifyStatic.SendOptions): FastifyReply; + download(filepath: string, filename?: string): FastifyReply; + download(filepath: string, filename?: string, options?: fastifyStatic.SendOptions): FastifyReply; } type FastifyStaticPlugin = FastifyPluginAsync>;