diff --git a/types/koa-convert/index.d.ts b/types/koa-convert/index.d.ts new file mode 100644 index 0000000000..ed5cd38480 --- /dev/null +++ b/types/koa-convert/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for koa-convert 1.2 +// Project: https://github.com/koajs/convert +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { Context, Middleware } from "koa"; + +declare function convert( + mw: (context: Context, next: () => void) => Generator +): Middleware; + +export = convert; diff --git a/types/koa-convert/koa-convert-tests.ts b/types/koa-convert/koa-convert-tests.ts new file mode 100644 index 0000000000..0a795e522b --- /dev/null +++ b/types/koa-convert/koa-convert-tests.ts @@ -0,0 +1,16 @@ +import convert = require('koa-convert'); +import Koa = require('koa'); + +const app = new Koa(); + +app.use(modernMiddleware); + +app.use(convert(legacyMiddleware)); + +function * legacyMiddleware(next: any) { + yield next; +} + +function modernMiddleware(ctx: Koa.Context, next: any) { + return next().then(() => {}); +} diff --git a/types/koa-convert/tsconfig.json b/types/koa-convert/tsconfig.json new file mode 100644 index 0000000000..c86211adaa --- /dev/null +++ b/types/koa-convert/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-convert-tests.ts" + ] +} diff --git a/types/koa-convert/tslint.json b/types/koa-convert/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/koa-convert/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}