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" +}