mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* Add types for mock-req-res * Remove <reference types directives * Refactor tests * Refactor tests * Fix dtslint errors * Fix dtslint errors * Update TypeScript version * Set TypeScript Version: 2.8
21 lines
931 B
TypeScript
21 lines
931 B
TypeScript
import { Request, Response, RequestHandler } from 'express';
|
|
import { mockRequest, mockResponse } from "mock-req-res";
|
|
|
|
const handler: RequestHandler = (req: Request, res: Response) => {
|
|
return res.status(200).json(`Hello from handler with an originalUrl value of '${req.originalUrl}'`);
|
|
};
|
|
|
|
const req = mockRequest({ originalUrl: "/" });
|
|
const res = mockResponse();
|
|
const next = () => {};
|
|
|
|
handler(req, res, next); // OK
|
|
|
|
// Argument of type '{}' is not assignable to parameter of type 'Request<Dictionary<string>>'.
|
|
// Type '{}' is missing the following properties from type 'Request<Dictionary<string>>': get, header, accepts, acceptsCharsets, and 72 more.t
|
|
// handler({}, res, next); // Error
|
|
|
|
// Argument of type '{}' is not assignable to parameter of type 'Response'.
|
|
// Type '{}' is missing the following properties from type 'Response': status, sendStatus, links, send, and 74 more.
|
|
// handler(req, {}, next); // Error
|