mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
Add typings for the package 'koa-cookie' (#41714)
* Add typings for the package koa-cookie * format with 4 spaces
This commit is contained in:
27
types/koa-cookie/index.d.ts
vendored
Normal file
27
types/koa-cookie/index.d.ts
vendored
Normal 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;
|
||||
13
types/koa-cookie/koa-cookie-tests.ts
Normal file
13
types/koa-cookie/koa-cookie-tests.ts
Normal 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);
|
||||
19
types/koa-cookie/tsconfig.json
Normal file
19
types/koa-cookie/tsconfig.json
Normal 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"
|
||||
]
|
||||
}
|
||||
3
types/koa-cookie/tslint.json
Normal file
3
types/koa-cookie/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user