From 9dad9b0e5c0cfab7568fc46868b6790c0065b3d9 Mon Sep 17 00:00:00 2001 From: Uzlopak Date: Mon, 8 Aug 2022 16:47:43 +0200 Subject: [PATCH] move types to types folder and fix typing (#330) --- package.json | 5 ++--- index.d.ts => types/index.d.ts | 4 ++-- test/types/index.ts => types/index.test-d.ts | 22 ++++++++++---------- 3 files changed, 15 insertions(+), 16 deletions(-) rename index.d.ts => types/index.d.ts (94%) rename test/types/index.ts => types/index.test-d.ts (83%) diff --git a/package.json b/package.json index adcfb41..4866b6f 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "6.5.0", "description": "Plugin for serving static files as fast as possible.", "main": "index.js", - "types": "index.d.ts", + "types": "types/index.d.ts", "scripts": { "lint": "standard | snazzy", "lint:fix": "standard --fix", @@ -53,8 +53,7 @@ "snazzy": "^9.0.0", "standard": "^17.0.0", "tap": "^16.0.0", - "tsd": "^0.22.0", - "typescript": "^4.0.2" + "tsd": "^0.22.0" }, "tsd": { "directory": "test/types" diff --git a/index.d.ts b/types/index.d.ts similarity index 94% rename from index.d.ts rename to types/index.d.ts index ac07ec4..5d6a7a8 100644 --- a/index.d.ts +++ b/types/index.d.ts @@ -2,7 +2,7 @@ // Leo /// -import { FastifyPluginCallback, FastifyReply, FastifyRequest } from 'fastify'; +import { FastifyPluginAsync, FastifyRequest } from 'fastify'; import { Stats } from 'fs'; declare module "fastify" { @@ -16,7 +16,7 @@ declare module "fastify" { } } -type FastifyStaticPlugin = FastifyPluginCallback>; +type FastifyStaticPlugin = FastifyPluginAsync>; declare namespace fastifyStatic { export interface ExtendedInformation { diff --git a/test/types/index.ts b/types/index.test-d.ts similarity index 83% rename from test/types/index.ts rename to types/index.test-d.ts index d596076..2dd0801 100644 --- a/test/types/index.ts +++ b/types/index.test-d.ts @@ -1,14 +1,14 @@ -import fastify, { FastifyInstance, FastifyPluginCallback, FastifyRequest } from 'fastify' +import fastify, { FastifyInstance, FastifyPluginAsync, FastifyRequest } from 'fastify' import { Server } from 'http'; import { expectAssignable, expectError, expectType } from 'tsd' -import * as fastifyStaticStar from '../..'; +import * as fastifyStaticStar from '..'; import fastifyStatic, { FastifyStaticOptions, fastifyStatic as fastifyStaticNamed, -} from '../..' +} from '..' -import fastifyStaticCjsImport = require('../..'); -const fastifyStaticCjs = require('../..'); +import fastifyStaticCjsImport = require('..'); +const fastifyStaticCjs = require('..'); const app: FastifyInstance = fastify(); @@ -20,12 +20,12 @@ app.register(fastifyStaticCjsImport.fastifyStatic); app.register(fastifyStaticStar.default); app.register(fastifyStaticStar.fastifyStatic); -expectType>(fastifyStatic); -expectType>(fastifyStaticNamed); -expectType>(fastifyStaticCjsImport.default); -expectType>(fastifyStaticCjsImport.fastifyStatic); -expectType>(fastifyStaticStar.default); -expectType>( +expectType>(fastifyStatic); +expectType>(fastifyStaticNamed); +expectType>(fastifyStaticCjsImport.default); +expectType>(fastifyStaticCjsImport.fastifyStatic); +expectType>(fastifyStaticStar.default); +expectType>( fastifyStaticStar.fastifyStatic ); expectType(fastifyStaticCjs);