[cookies] fix Cookies.get return type (#34860)

* [cookies] fix Cookies.get return type

If not exists cookie, return undefined.

* fix tests
This commit is contained in:
rinsuki
2019-04-19 17:11:20 -07:00
committed by Armando Aguirre
parent 4126a93ec0
commit bb68ba492c
3 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -10,9 +10,9 @@ const server = http.createServer((req, res) => {
new Cookies(req, res, {keys: new Keygrip([])});
new Cookies(req, res, {secure: true});
let unsigned: string;
let signed: string;
let tampered: string;
let unsigned: string | undefined;
let signed: string | undefined;
let tampered: string | undefined;
if (req.url === "/set") {
cookies
+1 -1
View File
@@ -22,7 +22,7 @@ interface Cookies {
* Cookie header in the request. If such a cookie exists,
* its value is returned. Otherwise, nothing is returned.
*/
get(name: string, opts?: Cookies.GetOption): string;
get(name: string, opts?: Cookies.GetOption): string | undefined;
/**
* This sets the given cookie in the response and returns
+2 -2
View File
@@ -6,7 +6,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
@@ -20,4 +20,4 @@
"index.d.ts",
"cookies-tests.ts"
]
}
}