From 1f418be731a07eee688e3897899eff6766cf9cc8 Mon Sep 17 00:00:00 2001 From: "Cao, Jiannan" Date: Tue, 12 Jul 2016 01:23:42 +0800 Subject: [PATCH] declare Express in ambient environment --- http-errors/http-errors-tests.d.ts | 6 ------ http-errors/http-errors-tests.ts | 9 ++++++++- 2 files changed, 8 insertions(+), 7 deletions(-) delete mode 100644 http-errors/http-errors-tests.d.ts diff --git a/http-errors/http-errors-tests.d.ts b/http-errors/http-errors-tests.d.ts deleted file mode 100644 index 9005c7ef41..0000000000 --- a/http-errors/http-errors-tests.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Type definitions for http-errors-tests.ts -declare namespace Express { - export interface Request { - user?: any - } -} diff --git a/http-errors/http-errors-tests.ts b/http-errors/http-errors-tests.ts index f8e0ea9b8c..61fb9091bf 100644 --- a/http-errors/http-errors-tests.ts +++ b/http-errors/http-errors-tests.ts @@ -1,12 +1,19 @@ /// /// -/// import * as createError from 'http-errors'; import * as express from 'express'; var app = express(); +declare global { + namespace Express { + export interface Request { + user?: any + } + } +} + app.use(function (req, res, next) { if (!req.user) return next(createError(401, 'Please login to view this page.')); next();