Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#71947 feat(jquery.cookie): fix `JQueryCook…
Browse files Browse the repository at this point in the history
…ieOptions.expires` type by @pistvan
  • Loading branch information
pistvan authored Feb 16, 2025
1 parent b5c91ca commit b4a1c75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion types/jquery.cookie/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ interface JQueryCookieOptions {
/**
* Define lifetime of the cookie. Value can be a Number which will be interpreted as days from time of creation or a Date object. If omitted, the cookie becomes a session cookie.
*/
expires?: any;
expires?: number | Date;
/**
* Define the path where the cookie is valid. By default the path of the cookie is the path of the page where the cookie was created (standard browser behavior). If you want to make it available for instance across the entire domain use path: '/'. Default: path of page where the cookie was created.
*/
Expand Down
7 changes: 7 additions & 0 deletions types/jquery.cookie/jquery.cookie-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ class CookieOptions implements JQueryCookieOptions {

$.cookie("the_cookie", "the_value");

$.cookie("the_cookie", "the_value", { expires: 7 });

$.cookie("the_cookie", "the_value", { expires: new Date() });

// @ts-expect-error
$.cookie("the_cookie", "the_value", { expires: "tomorrow" });

console.log($.cookie("the_cookie"));

var testObject = new TestObject("Hello World", 5);
Expand Down

0 comments on commit b4a1c75

Please sign in to comment.