v4.6.15
honojs/honov4.6.15Dec 28, 2024by yusukebe
AI Summary
This release adds type safety improvements to prevent using contentless status codes (like 204) with content-returning methods (`c.json()`, `c.text()`, `c.html()`). It also introduces cookie priority support and allows `ResponseInit` to accept generics for `StatusCode`.
Key Highlights
- Type error now thrown when using c.json(), c.text(), or c.html() with contentless status codes like 204
- Added ability to set priority to cookies in setCookie options
- ResponseInit now accepts generics for StatusCode
- Fixed jsr package to exclude unused markdown files
- Replaced Symbol with string for COMPOSED_HANDLER in hono-base
New Features
- Contentful status code typing - c.json()/c.text()/c.html() throw type error with 204 status
- ResponseInit accepts generics StatusCode for status parameter
- Cookie priority support in setCookie options
Full Release Notes
## `c.json()` etc. throwing type error when the status is contentless code, e.g., 204
From this release, when `c.json()`, `c.text()`, or `c.html()` returns content, specifying a contentless status code such as 204 will now throw a type error.

At first glance, this seems like a breaking change but not. It is not possible to return a contentless response with `c.json()` or `c.text()`. So, in that case, please use `c.body()`.
```ts
app.get('/', (c) => {
return c.body(null, 204)
})
```
## What's Changed
* fix(jsr): exclude unused markdown files by @ryuapp in https://github.com/honojs/hono/pull/3767
* feat(hono/context): contentful status code typing by @askorupskyy in https://github.com/honojs/hono/pull/3763
* refactor(context): remove lint errors by @yusukebe in https://github.com/honojs/hono/pull/3769
* feat(context): `ResponseInit` accepts generics `StatusCode` for `status` by @yusukebe in https://github.com/honojs/hono/pull/3770
* feat(utils/cookie): Ability to set a priority to cookies in setCookie options by @Beyondo in https://github.com/honojs/hono/pull/3762
* fix(hono-base): don't use Symbol for `COMPOSED_HANDLER` by @yusukebe in https://github.com/honojs/hono/pull/3773
## New Contributors
* @askorupskyy made their first contribution in https://github.com/honojs/hono/pull/3763
* @Beyondo made their first contribution in https://github.com/honojs/hono/pull/3762
**Full Changelog**: https://github.com/honojs/hono/compare/v4.6.14...v4.6.15