Skip to content

fix(types): document cookie secure and httpOnly defaults as true - #353

Merged
Tony133 merged 2 commits into
fastify:mainfrom
Hashim1999164:fix/cookie-secure-httponly-types-299
Jul 28, 2026
Merged

fix(types): document cookie secure and httpOnly defaults as true#353
Tony133 merged 2 commits into
fastify:mainfrom
Hashim1999164:fix/cookie-secure-httponly-types-299

Conversation

@Hashim1999164

Copy link
Copy Markdown
Contributor

Summary

  • Re-declare httpOnly and secure on CookieOptions with @default true JSDoc so IDE tooltips match runtime and README behavior.
  • Previously these fields were inherited from @fastify/cookie CookieSerializeOptions, which documents defaults as false.

Fixes #299

Test plan

  • npm run test:typescript
  • npm run test:unit (100% coverage)

Align CookieOptions JSDoc with runtime and README defaults so editors
no longer inherit @fastify/cookie false defaults.

Fixes fastify#299
@Tony133

Tony133 commented Jul 27, 2026

Copy link
Copy Markdown
Member

The fix looks great! Could you also update the type test file to include assertions for httpOnly and secure on CookieOptions?

see here: https://github.com/fastify/session/blob/main/types/index.tst.ts#L59

- const cookieMaxAge: CookieOptions = {}
- expect(cookieMaxAge.maxAge).type.toBe<number | undefined>()

+ const cookieOptions: CookieOptions = {}
+ expect(cookieOptions.maxAge).type.toBe<number | undefined>()
+ expect(cookieOptions.httpOnly).type.toBe<boolean | undefined>()
+ expect(cookieOptions.secure).type.toBe<boolean | 'auto' | undefined>()

@Hashim1999164

Copy link
Copy Markdown
Contributor Author

Updated types/index.tst.ts with assertions for httpOnly and secure on CookieOptions as requested.

@Tony133 Tony133 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@Tony133
Tony133 merged commit ee47908 into fastify:main Jul 28, 2026
14 checks passed
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.

Documentation discrepancy for cookie: secure option

2 participants