From f502e26e8c8680759c93129e115f44c4d6eb2080 Mon Sep 17 00:00:00 2001 From: Daniel Byrne Date: Tue, 28 Aug 2018 15:45:57 -0700 Subject: [PATCH] adds typings for the 'koa-better-body' package --- types/koa-better-body/index.d.ts | 33 +++++++++++++++++++ .../koa-better-body/koa-better-body-tests.ts | 11 +++++++ types/koa-better-body/tsconfig.json | 19 +++++++++++ types/koa-better-body/tslint.json | 3 ++ 4 files changed, 66 insertions(+) create mode 100644 types/koa-better-body/index.d.ts create mode 100644 types/koa-better-body/koa-better-body-tests.ts create mode 100644 types/koa-better-body/tsconfig.json create mode 100644 types/koa-better-body/tslint.json diff --git a/types/koa-better-body/index.d.ts b/types/koa-better-body/index.d.ts new file mode 100644 index 0000000000..ab7cf5b21f --- /dev/null +++ b/types/koa-better-body/index.d.ts @@ -0,0 +1,33 @@ +// Type definitions for koa-better-body 3.0 +// Project: https://github.com/tunnckoCore/koa-better-body +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { Context } from 'koa'; + +declare function KoaBetterBody(options?: KoaBetterBody.Options): KoaBetterBody.Body; + +declare namespace KoaBetterBody { + interface Options { + fields?: boolean | string; + files?: boolean | string; + multipart?: boolean; + textLimit?: string; + formLimit?: string; + urlencodedLimit?: string; + jsonLimit?: string; + bufferLimit?: string; + jsonStrict?: boolean; + detectJSON?: () => any; + strict?: boolean; + delimiter?: symbol; + decodeURIComponent?: any; + maxKeys?: number; + buffer?: boolean; + } + + type Body = (context: Context, next: () => void) => Generator; +} + +export = KoaBetterBody; diff --git a/types/koa-better-body/koa-better-body-tests.ts b/types/koa-better-body/koa-better-body-tests.ts new file mode 100644 index 0000000000..2f4deb2d49 --- /dev/null +++ b/types/koa-better-body/koa-better-body-tests.ts @@ -0,0 +1,11 @@ +import body = require('koa-better-body'); + +// $ExpectType Body +body(); + +const testOptions: body.Options = { + jsonLimit: '100mb', +}; + +// $ExpectType Body +body(testOptions); diff --git a/types/koa-better-body/tsconfig.json b/types/koa-better-body/tsconfig.json new file mode 100644 index 0000000000..74a794a11c --- /dev/null +++ b/types/koa-better-body/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "koa-better-body-tests.ts" + ] +} diff --git a/types/koa-better-body/tslint.json b/types/koa-better-body/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/koa-better-body/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}