From fef2c8c6167637d1d814bdeff19703ec3ba60286 Mon Sep 17 00:00:00 2001 From: Xiaohan Zhang Date: Wed, 24 Jan 2018 11:57:46 -0500 Subject: [PATCH] Add express-to-koa definition (#23153) * Add express-to-koa definition * Fix types --- types/express-to-koa/express-to-koa-tests.ts | 12 ++++++++++ types/express-to-koa/index.d.ts | 18 +++++++++++++++ types/express-to-koa/tsconfig.json | 23 ++++++++++++++++++++ types/express-to-koa/tslint.json | 1 + 4 files changed, 54 insertions(+) create mode 100644 types/express-to-koa/express-to-koa-tests.ts create mode 100644 types/express-to-koa/index.d.ts create mode 100644 types/express-to-koa/tsconfig.json create mode 100644 types/express-to-koa/tslint.json diff --git a/types/express-to-koa/express-to-koa-tests.ts b/types/express-to-koa/express-to-koa-tests.ts new file mode 100644 index 0000000000..73b6ae480a --- /dev/null +++ b/types/express-to-koa/express-to-koa-tests.ts @@ -0,0 +1,12 @@ +import * as Koa from 'koa'; +import * as connect from 'connect'; +import expressToKoa = require('express-to-koa'); + +const app = new Koa(); +const middleware: connect.NextHandleFunction = (req, res, next) => { + // 'express middleware' + next(); +}; + +app.use(expressToKoa(middleware)); +app.listen(3000); diff --git a/types/express-to-koa/index.d.ts b/types/express-to-koa/index.d.ts new file mode 100644 index 0000000000..9a23108943 --- /dev/null +++ b/types/express-to-koa/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for express-to-koa 1.0 +// Project: https://github.com/kaelzhang/express-to-koa +// Definitions by: Xiaohan Zhang +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import * as Koa from "koa"; +import { IncomingMessage, ServerResponse } from "http"; + +export = expressToKoa; + +declare function expressToKoa( + middleware: ( + req: IncomingMessage, + res: ServerResponse, + next: (err?: any) => void, + ) => void +): Koa.Middleware; diff --git a/types/express-to-koa/tsconfig.json b/types/express-to-koa/tsconfig.json new file mode 100644 index 0000000000..9c27ef439f --- /dev/null +++ b/types/express-to-koa/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "express-to-koa-tests.ts" + ] +} diff --git a/types/express-to-koa/tslint.json b/types/express-to-koa/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/express-to-koa/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }