H
Hono2mo ago
Jannis

Need help with typescript

import { Hono } from 'hono' import githubApp from './routes/github' const app = new Hono() const welcomeStrings = [ 'Hello Hono!', 'To learn more about Hono on Vercel, visit https://vercel.com/docs/frameworks/hono' ] app.get('/', (c) => { return c.text(welcomeStrings.join('\n\n')) }) export default app I have this basic index.ts but i cant import the github.ts like that my code editor tells me to use .js but that doenst look right
6 Replies
Jannis
JannisOP2mo ago
{ "compilerOptions": { "target": "ESNext", "module": "NodeNext", "strict": true, "skipLibCheck": true, "types": ["node"], "jsx": "react-jsx", "jsxImportSource": "hono/jsx", "outDir": "./dist", "paths": { "@/*": [ "./src/*" ] } }, "exclude": ["node_modules"] }
blair
blair2mo ago
This is a typescript/nodejs thing, not a hono thing, but you're looking for the allowImportingTsExtensions key in tsconfig.json You'll need something that can process typescript files though, ie you're using ts-node or some equivalent, or some other runtime that supports it (workerd, bun)
Arjix
Arjix2mo ago
nodejs can process typescript files! it doesn't do type checking and merely strips the types so stuff like enums won't work
Arjix
Arjix2mo ago
No description
blair
blair2mo ago
Isn't it still experimental (and require a flag)?
Arjix
Arjix2mo ago
it doesn't require a flag on v24 https://nodejs.org/docs/latest-v24.x/api/typescript.html#typescript-features it is a release candidate
Release candidate. Experimental features at this stage are hopefully ready to become stable. No further breaking changes are anticipated but may still occur in response to user feedback or the features' underlying specification development. We encourage user testing and feedback so that we can know that this feature is ready to be marked as stable.
since it doesn't do transformations and only supports stripping types, I wouldn't worry about it not working one thing that doesn't work is typescript path aliases, since it'd require to either transform the import or to depend on the tsconfig

Did you find this page helpful?