honojs/hono

Importing the StatusCode type from http-status in a project gives a typescript error

Closed this issue · 2 comments

What version of Hono are you using?

4.3.2

What runtime/platform is your app running on?

Cloudflare Workers

What steps can reproduce the bug?

At least when using the Jetbrains IntelliJ / webstorm ide, importing the http StatusCode works, but gives a typescript error, because it isn't an exported type from src/index.ts, and instead has to be imported like this:
import type {StatusCode} from "hono/dist/types/utils/http-status";

What is the expected behavior?

let status code be directly imported from Hono like

import type {StatusCode} from "Hono"
// or
import type {StatusCode} from "Hono.Utils"

What do you see instead?

a typescript error when using the dist workaround

Additional information

Importing this type is rather important when implementing custom error handling, especially since you can't directly cast number to StatusCode

If my comment is mistaken, ignore me.
Is it good?

import { StatusCode } from 'hono/utils/http-status'

yup that works- my mistake, I missed that one completely