[cookies] Fix Cookies.set signature for omittingvalue (#38400)

* [cookies] Added breaking test for Cookies.set

* [cookies] Fix Cookies.set sig for omitting `value`

When omitting the `value` parameter the signature assumes you have omitted the `opts` parameter and causes an error
because the types don't match
This commit is contained in:
Fabien O'Carroll
2019-09-16 11:05:21 -07:00
committed by Daniel Rosenwasser
parent 569992f619
commit e3a3f18d94
2 changed files with 5 additions and 1 deletions
+3
View File
@@ -26,6 +26,9 @@ const server = http.createServer((req, res) => {
.set("tampered", "baz")
.set("tampered.sig", "bogus")
// delete cookie but pass options
.set("removed", { signed: true })
// sameSite option
.set("samesite", "same", {sameSite: 'lax'})
.set("samesite", "same", {sameSite: 'strict'})
+2 -1
View File
@@ -29,7 +29,8 @@ interface Cookies {
* the current context to allow chaining.If the value is omitted,
* an outbound header with an expired date is used to delete the cookie.
*/
set(name: string, value?: string, opts?: Cookies.SetOption): this;
set(name: string, value: string, opts?: Cookies.SetOption): this;
set(name: string, opts?: Cookies.SetOption): this;
}
declare namespace Cookies {