@@ -50,7 +50,7 @@ export enum SameSite
5050 * Interface representing Cookie properties before it get parsed.
5151 *
5252 */
53- export interface RawCookie < K = string , V = string >
53+ export interface RawCookie < K = string , V = unknown >
5454{
5555 /**
5656 * The Cookie name.
@@ -124,7 +124,7 @@ export interface RawCookie<K = string, V = string>
124124 * Interface representing Cookie properties after it get parsed.
125125 *
126126 */
127- export interface ParsedCookie < K = string , V = string > extends Omit < RawCookie < K , V > , 'expires' >
127+ export interface ParsedCookie < K = string , V = unknown > extends Omit < RawCookie < K , V > , 'expires' >
128128{
129129 /**
130130 * Indicates the maximum lifetime of the cookie.
@@ -139,7 +139,7 @@ export interface ParsedCookie<K = string, V = string> extends Omit<RawCookie<K,
139139 * Map representation of a parsed Cookie.
140140 *
141141 */
142- export type ParsedCookieMap < K = string , V = string > = TypedMap < ParsedCookie < K , V > , false >
142+ export type ParsedCookieMap < K = string , V = unknown > = TypedMap < ParsedCookie < K , V > , false >
143143
144144
145145/**
@@ -169,7 +169,7 @@ export class Cookie
169169 * @param options The cookie options or a parsed Cookie Map.
170170 * @returns The set Cookie Map if successful, `false` otherwise.
171171 */
172- static set < K = string , V = string > ( options : RawCookie < K , V > | ParsedCookieMap < K , V > )
172+ static set < K = string , V = unknown > ( options : RawCookie < K , V > | ParsedCookieMap < K , V > )
173173 {
174174 const cookie = options instanceof Map ? options : Cookie . parse ( options )
175175
@@ -205,7 +205,7 @@ export class Cookie
205205 * @param options The Cookie options.
206206 * @returns The parsed Cookie Map.
207207 */
208- static parse < K = string , V = string > ( options : RawCookie < K , V > ) : ParsedCookieMap < K , V >
208+ static parse < K = string , V = unknown > ( options : RawCookie < K , V > ) : ParsedCookieMap < K , V >
209209 {
210210 const expires = options . expires ? new Date ( options . expires ) : undefined
211211 const cookie = getTypedMap < ParsedCookie < K , V > , false > ( )
@@ -234,7 +234,7 @@ export class Cookie
234234 * @param options The cookie options or a parsed Cookie Map.
235235 * @returns The stringified Cookie ready to be stored.
236236 */
237- static toString < K = string , V = string > ( options : RawCookie < K , V > | ParsedCookieMap < K , V > )
237+ static toString < K = string , V = unknown > ( options : RawCookie < K , V > | ParsedCookieMap < K , V > )
238238 {
239239 const cookie = options instanceof Map ? options : Cookie . parse ( options )
240240
@@ -249,8 +249,7 @@ export class Cookie
249249 return (
250250 [ nameValue , ...values ]
251251 . map ( ( [ key , value ] ) => {
252- if ( ! key ) return null
253- key = key !== name ? ucFirst ( key . toString ( ) ) as K : key
252+ key = key !== name ? ucFirst ( key ! . toString ( ) ) as K : key
254253
255254 if ( key === 'Expires' && isValidDate ( value ) ) {
256255 value = value . toUTCString ( )
@@ -273,7 +272,7 @@ export class Cookie
273272 * @param cookie The cookie string.
274273 * @returns The parsed Cookie Map or `null` if parsing fails.
275274 */
276- static fromString < K = string , V = string > ( cookie : string ) : ParsedCookieMap < K , V > | null
275+ static fromString < K = string , V = unknown > ( cookie : string ) : ParsedCookieMap < K , V > | null
277276 {
278277 const [ kv , ...rawValues ] = cookie . split ( ';' )
279278
0 commit comments