DefinitelyTyped/types/express-flash-2/index.d.ts
Oliver Joseph Ash 3cd6ad7fa4 Express: use generics for params, default to dictionary (#37718)
* Revert "Express: improve type of `Request['params']` aka `req.params` (#37502)"

This reverts commit 9aa863ef23.

* Express: use generics for params, default to dictionary

* Lint

* Bump all dependants

* Spacing

* Bump dependants

* Bump dependants

* Bump dependants

* Bump dependants

* Bump dependants

* Bump dependants

* Bump dependants

* Bump dependants

* Bump dependants

* Bump dependants

* Bump dependants (via tests)

* Bump dependants

* Bump dependants (via tests)

* Bump dependants

* Simplify test

* Hoist imports

* Tidy test

* Add tests

* Add reasons

* Remove redundant params

* Add tests

* Format

* Remove redundant params

* Add tests

* Add JSDoc

* Improve comment

* Improve comment
2019-08-18 17:47:36 -07:00

59 lines
1.6 KiB
TypeScript

// 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
// TypeScript Version: 2.3
import express = require('express');
/**
* Expose `flash()` function on responses.
*/
declare function flash(): express.RequestHandler;
export = flash;
declare global {
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
};
}
}
}