From bc54a53ac573fb2ff8d48d694c5af5696f7eda17 Mon Sep 17 00:00:00 2001 From: Niklas Mollenhauer Date: Mon, 4 Sep 2017 22:30:23 +0200 Subject: [PATCH] Use inherited `writeHead` method signature The `writeHead` method gets passed through to the native `response.writeHead`. The `Response` interface extends `http.ServerResponse` which defined the `writeHead` method with different arguments. For maintainability reasons, we should just use the inherited method. Also, the current definition makes this method useless (`writeHead` expects at lease one argument). --- types/restify/index.d.ts | 9 --------- types/restify/restify-tests.ts | 5 ++++- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/types/restify/index.d.ts b/types/restify/index.d.ts index e32433cb01..e7b5629ded 100644 --- a/types/restify/index.d.ts +++ b/types/restify/index.d.ts @@ -919,15 +919,6 @@ export interface Response extends http.ServerResponse { */ toString(): string; - /** - * pass through to native response.writeHead(). - * @public - * @function writeHead - * @emits header - * @returns {undefined} - */ - writeHead(): void; - /** redirect is sugar method for redirecting. * res.redirect(301, 'www.foo.com', next); * `next` is mandatory, to complete the response and trigger audit logger. diff --git a/types/restify/restify-tests.ts b/types/restify/restify-tests.ts index 1c1f1cee40..ade6ce3898 100644 --- a/types/restify/restify-tests.ts +++ b/types/restify/restify-tests.ts @@ -95,7 +95,10 @@ function send(req: restify.Request, res: restify.Response, next: restify.Next) { res.id === 'test'; res.send('hello ' + req.params.name); - res.writeHead(); + res.writeHead(200); + res.writeHead(200, { + "Content-Type": "application/json" + }); return next(); }