Merge pull request #17016 from zaggino/express

express header methods can return undefined
This commit is contained in:
Mine Starks
2017-06-15 11:20:52 -07:00
committed by GitHub
5 changed files with 15 additions and 5 deletions
+3 -3
View File
@@ -197,11 +197,11 @@ interface Request extends http.IncomingMessage, Express.Request {
*
* @param name
*/
get(name: string): string;
get(name: string): string | undefined;
header(name: string): string;
header(name: string): string | undefined;
headers: { [key: string]: string; };
headers: { [key: string]: string | undefined; };
/**
* Check if the given `type(s)` is acceptable, returning
@@ -6,7 +6,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
+9
View File
@@ -71,6 +71,15 @@ namespace express_tests {
language = req.acceptsLanguages(['en', 'ja']);
language = req.acceptsLanguages('en', 'ja');
let existingHeader1 = req.get('existingHeader') as string;
let nonExistingHeader1 = req.get('nonExistingHeader') as undefined;
let existingHeader2 = req.header('existingHeader') as string;
let nonExistingHeader2 = req.header('nonExistingHeader') as undefined;
let existingHeader3 = req.headers.existingHeader as string;
let nonExistingHeader3 = req.headers.nonExistingHeader as undefined;
res.send(req.query['token']);
});
+1
View File
@@ -2,6 +2,7 @@
// Project: http://expressjs.com
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/* =================== USAGE ===================
+1 -1
View File
@@ -6,7 +6,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"