mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-22 11:57:33 +08:00
Merge pull request #17725 from mathsalmi/master
Add type definitions for express-flash-2
This commit is contained in:
3
types/express-flash-2/express-flash-2-tests.ts
Normal file
3
types/express-flash-2/express-flash-2-tests.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import flash from "express-flash-2";
|
||||
|
||||
flash();
|
||||
57
types/express-flash-2/index.d.ts
vendored
Normal file
57
types/express-flash-2/index.d.ts
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
// Type definitions for express-flash-2 1.0
|
||||
// Project: https://github.com/jack2gs/express-flash-2
|
||||
// Definitions by: Matheus Salmi <https://github.com/mathsalmi/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace Express {
|
||||
interface Request {
|
||||
session?: Session;
|
||||
}
|
||||
|
||||
interface Session {
|
||||
flash: Flash;
|
||||
}
|
||||
|
||||
interface Flash {
|
||||
[key: string]: any[];
|
||||
}
|
||||
|
||||
interface Response {
|
||||
/**
|
||||
* Queue flash `msg` of the given `type`.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* req.flash('info', 'email sent');
|
||||
* req.flash('error', 'email delivery failed');
|
||||
* req.flash('info', 'email re-sent');
|
||||
*
|
||||
*
|
||||
* Formatting:
|
||||
*
|
||||
* Flash notifications also support arbitrary formatting support.
|
||||
* For example you may pass variable arguments to `req.flash()`
|
||||
* and use the %s specifier to be replaced by the associated argument:
|
||||
*
|
||||
* req.flash('info', 'email has been sent to %s.', userName);
|
||||
*
|
||||
* Formatting uses `util.format()`, which is available on Node 0.6+.
|
||||
*/
|
||||
flash(type: string, msg: string | any[]): void;
|
||||
|
||||
locals: {
|
||||
flash: Flash
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'express-flash-2' {
|
||||
import express = require('express');
|
||||
|
||||
/**
|
||||
* Expose `flash()` function on responses.
|
||||
*/
|
||||
function flash(): express.RequestHandler;
|
||||
|
||||
export = flash;
|
||||
}
|
||||
22
types/express-flash-2/tsconfig.json
Normal file
22
types/express-flash-2/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"express-flash-2-tests.ts"
|
||||
]
|
||||
}
|
||||
8
types/express-flash-2/tslint.json
Normal file
8
types/express-flash-2/tslint.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-single-declare-module": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"expect": false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user