js-cookie: last review fixes #32830

This commit is contained in:
Erik Krogh Kristensen 2019-02-08 13:18:40 +01:00
parent 08a32bb403
commit dfd742bfd2
2 changed files with 3 additions and 3 deletions

View File

@ -79,7 +79,7 @@ declare namespace Cookies {
* or SDK. Note: The noConflict method is not necessary when using
* AMD or CommonJS, thus it is not exposed in those environments.
*/
noConflict?(): CookiesStatic;
noConflict?(): CookiesStatic<T>;
/**
* Create a new instance of the api that overrides the default
@ -88,7 +88,7 @@ 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<T>; read: CookieReadConverter; }): CookiesStatic;
withConverter<TConv extends object>(converter: CookieReadConverter | { write: CookieWriteConverter<TConv>; read: CookieReadConverter; }): CookiesStatic<TConv>;
}
type CookieWriteConverter<T extends object> = (value: string | T, name: string) => string;

View File

@ -40,7 +40,7 @@ cookies.get('escaped');
Cookies.defaults.path = '';
delete Cookies.defaults.path;
const PHPCookies = Cookies.withConverter({
const PHPCookies = Cookies.withConverter<object>({
write(value) {
value; // $ExpectType string | object
return encodeURIComponent(value as string)