mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
js-cookie: parameterized set value
This commit is contained in:
Vendored
+4
-4
@@ -33,7 +33,7 @@ declare namespace Cookies {
|
||||
secure?: boolean;
|
||||
}
|
||||
|
||||
interface CookiesStatic {
|
||||
interface CookiesStatic<T extends object = object> {
|
||||
/**
|
||||
* Allows default cookie attributes to be accessed, changed, or reset
|
||||
*/
|
||||
@@ -42,7 +42,7 @@ declare namespace Cookies {
|
||||
/**
|
||||
* Create a cookie
|
||||
*/
|
||||
set(name: string, value: string | object, options?: CookieAttributes): void;
|
||||
set(name: string, value: string | T, options?: CookieAttributes): void;
|
||||
|
||||
/**
|
||||
* Read cookie
|
||||
@@ -88,10 +88,10 @@ declare namespace Cookies {
|
||||
* will run the converter first for each cookie. The returned
|
||||
* string will be used as the cookie value.
|
||||
*/
|
||||
withConverter(converter: CookieReadConverter | { write: CookieWriteConverter; read: CookieReadConverter; }): CookiesStatic;
|
||||
withConverter(converter: CookieReadConverter | { write: CookieWriteConverter<T>; read: CookieReadConverter; }): CookiesStatic;
|
||||
}
|
||||
|
||||
type CookieWriteConverter = (value: string | object, name: string) => string;
|
||||
type CookieWriteConverter<T extends object> = (value: string | T, name: string) => string;
|
||||
type CookieReadConverter = (value: string, name: string) => string;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ Cookies.remove('name');
|
||||
Cookies.remove('name', { path: '' });
|
||||
|
||||
const Cookies2 = Cookies.noConflict!();
|
||||
Cookies2; // $ExpectType CookiesStatic
|
||||
Cookies2; // $ExpectType CookiesStatic<object>
|
||||
|
||||
Cookies.set('name', { foo: 'bar' });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user