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

Update Request Cookies Type to Add undefined #190

Merged
merged 3 commits into from
Jul 15, 2022
Merged

Update Request Cookies Type to Add undefined #190

merged 3 commits into from
Jul 15, 2022

Conversation

ryanagillie
Copy link
Contributor

@ryanagillie ryanagillie commented Jul 1, 2022

Updates the TypeScript types to add | undefined to a request's cookies.

This is a breaking change as previously cookies were typed to be a string, while now that cannot be assumed. (Possibly 7.1.0?)

Checklist

@ryanagillie
Copy link
Contributor Author

ryanagillie commented Jul 1, 2022

Are the tests okay? I didn't exactly know how to test the types other than throwing the expectType<string | undefined>(test); in the very first one. I know I had to non-null assert the request.cookies.test to make it work.

I did add runtime checks to show that cookies can be undefined.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm, this looks good!

@mcollina mcollina merged commit 2bdb61e into fastify:master Jul 15, 2022
@ryanagillie ryanagillie deleted the cookie-types-undefined branch July 15, 2022 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants