Add typings for the package 'koa-cookie' (#41714)

* Add typings for the package koa-cookie

* format with 4 spaces
This commit is contained in:
John Hou
2020-01-21 07:56:23 +08:00
committed by Eli Barzilay
parent 6177b2e997
commit c16fefbe65
4 changed files with 62 additions and 0 deletions

27
types/koa-cookie/index.d.ts vendored Normal file
View File

@@ -0,0 +1,27 @@
// Type definitions for koa-cookie 1.0
// Project: https://github.com/varunpal/koa-cookie
// Definitions by: John Hou <https://github.com/dancon>
// 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<string, any>;
}
}
declare function cookie(): Middleware;
export = cookie;

View File

@@ -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);

View File

@@ -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"
]
}

View File

@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}