diff --git a/types/koa-cookie/index.d.ts b/types/koa-cookie/index.d.ts new file mode 100644 index 0000000000..1da90209bd --- /dev/null +++ b/types/koa-cookie/index.d.ts @@ -0,0 +1,27 @@ +// Type definitions for koa-cookie 1.0 +// Project: https://github.com/varunpal/koa-cookie +// Definitions by: John Hou +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/* =================== USAGE =================== + + import cookie = require("koa-cookie"); + import Koa = require('koa'); + + const app = new Koa(); + app.use(cookie()); + + =============================================== */ + +import { Middleware } from 'koa'; + +declare module 'koa' { + interface BaseContext { + cookie: Record; + } +} + +declare function cookie(): Middleware; + +export = cookie; diff --git a/types/koa-cookie/koa-cookie-tests.ts b/types/koa-cookie/koa-cookie-tests.ts new file mode 100644 index 0000000000..61c5ed6f1e --- /dev/null +++ b/types/koa-cookie/koa-cookie-tests.ts @@ -0,0 +1,13 @@ +import Koa = require('koa'); +import cookie = require('koa-cookie'); + +const app = new Koa(); + +app.use(cookie()); + +app.use((ctx) => { + const cookie = ctx.cookie; + console.log(cookie); +}); + +app.listen(8080); diff --git a/types/koa-cookie/tsconfig.json b/types/koa-cookie/tsconfig.json new file mode 100644 index 0000000000..44456486cc --- /dev/null +++ b/types/koa-cookie/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-cookie-tests.ts" + ] +} diff --git a/types/koa-cookie/tslint.json b/types/koa-cookie/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/koa-cookie/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}