Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): manually Pick and Omit from CookieSerializeOptions interface #10767

Closed
wants to merge 2 commits into from

Conversation

lilnasy
Copy link
Contributor

@lilnasy lilnasy commented Apr 12, 2024

Changes

  • Fixes an issue where all options of Astro.cookies.set and Astro.cookies.delete were incorrectly reported as required.

Testing

  • Existing tests should pass.

Docs

  • Does not affect usage.

Copy link

changeset-bot bot commented Apr 12, 2024

🦋 Changeset detected

Latest commit: ad76a00

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Apr 12, 2024
Copy link
Member

@florian-lefebvre florian-lefebvre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use a partial + a mapped type to allow undefined (maybe there's one built-in TS?) instead? Having to maintain the jsdoc annotations is not ideal imo. We also probably want to do this for the get options

@lilnasy
Copy link
Contributor Author

lilnasy commented Apr 12, 2024

We could but users lose typedocs that way.

I don't think maintainability is much of a concern for this part of the codebase, it's very low traffic.

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a good comprise, especially if the file is rarely modified.

@florian-lefebvre
Copy link
Member

I guess it's superseded by #10776?

CookieSerializeOptions,
'domain' | 'path' | 'expires' | 'maxAge' | 'httpOnly' | 'sameSite' | 'secure' | 'encode'
>;
// `AstroCookieSetOptions` and `AstroCookieDeleteOptions` are manually copied subsections of `CookieSerializeOptions` because `Omit` and `Pick` result in all fields being required.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason it cannot be Partial<Pick...?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's because jsdoc annotations are lost anyway

@Princesseuh
Copy link
Member

Closing since it seems like this is not relevant anymore with the PR Florian linked.

@lilnasy lilnasy deleted the fix-cookie-types branch May 23, 2024 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants