From 38e3983a9e2e12624daf5a323b38f5f6e9d99b91 Mon Sep 17 00:00:00 2001 From: Jan Dolezel Date: Mon, 8 Apr 2019 12:00:37 +0200 Subject: [PATCH 1/2] TS definitions for multy --- types/multy/index.d.ts | 20 ++++++++++++++++++++ types/multy/multy-tests.ts | 3 +++ types/multy/tsconfig.json | 24 ++++++++++++++++++++++++ types/multy/tslint.json | 1 + 4 files changed, 48 insertions(+) create mode 100644 types/multy/index.d.ts create mode 100644 types/multy/multy-tests.ts create mode 100644 types/multy/tsconfig.json create mode 100644 types/multy/tslint.json diff --git a/types/multy/index.d.ts b/types/multy/index.d.ts new file mode 100644 index 0000000000..dfa793ae57 --- /dev/null +++ b/types/multy/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for multy 0.1 +// Project: https://github.com/eduardorfs/multy +// Definitions by: Jan Dolezel +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +import * as Koa from "koa"; +import * as busboy from "busboy"; + +declare module "koa" { + interface Request { + body: any; + } +} + +declare function multy(opts?: busboy.BusboyConfig): Koa.Middleware; + +declare namespace multy {} + +export = multy; diff --git a/types/multy/multy-tests.ts b/types/multy/multy-tests.ts new file mode 100644 index 0000000000..36303ab8e6 --- /dev/null +++ b/types/multy/multy-tests.ts @@ -0,0 +1,3 @@ +import createMultyMiddleware = require("multy"); + +const middleware = createMultyMiddleware(); diff --git a/types/multy/tsconfig.json b/types/multy/tsconfig.json new file mode 100644 index 0000000000..9b6ece72d9 --- /dev/null +++ b/types/multy/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "multy-tests.ts" + ] +} diff --git a/types/multy/tslint.json b/types/multy/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/multy/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From cb372a6b4e41df647dcf8f959df400f839bd4658 Mon Sep 17 00:00:00 2001 From: Jan Dolezel Date: Tue, 9 Apr 2019 08:16:39 +0200 Subject: [PATCH 2/2] Added type for options for better backward compatibility in future --- types/multy/index.d.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/types/multy/index.d.ts b/types/multy/index.d.ts index dfa793ae57..ee9ee1079d 100644 --- a/types/multy/index.d.ts +++ b/types/multy/index.d.ts @@ -13,8 +13,10 @@ declare module "koa" { } } -declare function multy(opts?: busboy.BusboyConfig): Koa.Middleware; +declare namespace multy { + type Options = busboy.BusboyConfig; +} -declare namespace multy {} +declare function multy(opts?: multy.Options): Koa.Middleware; export = multy;