mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
Merge pull request #17016 from zaggino/express
express header methods can return undefined
This commit is contained in:
+3
-3
@@ -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": [
|
||||
"../"
|
||||
|
||||
@@ -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']);
|
||||
});
|
||||
|
||||
|
||||
Vendored
+1
@@ -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 ===================
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
|
||||
Reference in New Issue
Block a user