[finalhandler] Align types with usage as found in github repo.

The structure of `options` and the declaration as `finalhandler` and not
`finalHandler` as found in the latest release:

  https://github.com/pillarjs/finalhandler/blob/v1.1.1/index.js#L84
This commit is contained in:
Mark Veronda
2019-04-02 17:43:48 -07:00
parent 65b88d6a56
commit a96c7aabd4
2 changed files with 15 additions and 15 deletions

View File

@@ -1,15 +1,14 @@
import { IncomingMessage, ServerResponse } from "http";
import finalHandler = require("finalhandler");
import finalhandler = require("finalhandler");
let req: IncomingMessage;
let res: ServerResponse;
let options: {
onerror: (err: any, req: IncomingMessage, res: ServerResponse) => void;
message: boolean|((err: any, status: number) => string);
stacktrace: boolean;
env: string;
onerror: (err: any, req: IncomingMessage, res: ServerResponse) => void;
};
let result: (err: any) => void;
result = finalHandler(req, res);
result = finalHandler(req, res, options);
result = finalhandler(req, res);
result = finalhandler(req, res, options);

View File

@@ -1,20 +1,21 @@
// Type definitions for finalhandler
// Project: https://github.com/pillarjs/finalhandler
// Definitions by: Ilya Mochalov <https://github.com/chrootsu>
// Mark Veronda <https://github.com/hbomark>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import { IncomingMessage, ServerResponse } from "http";
import { IncomingMessage, ServerResponse } from 'http';
declare function finalHandler(req: IncomingMessage, res: ServerResponse, options?: finalHandler.Options): (err: any) => void;
declare function finalhandler(req: IncomingMessage, res: ServerResponse,
options?: finalhandler.Options): (err: any) => void;
declare namespace finalHandler {
export interface Options {
message?: boolean|((err: any, status: number) => string);
onerror?: (err: any, req: IncomingMessage, res: ServerResponse) => void;
stacktrace?: boolean;
}
declare namespace finalhandler {
export interface Options {
env?: string,
onerror?: (err: any, req: IncomingMessage, res: ServerResponse) => void;
}
}
export = finalHandler;
export = finalhandler;