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

Type error when using "moduleResolution": "node16" in tsconfig. #668

Closed
universse opened this issue Nov 19, 2022 · 7 comments · Fixed by #669
Closed

Type error when using "moduleResolution": "node16" in tsconfig. #668

universse opened this issue Nov 19, 2022 · 7 comments · Fixed by #669

Comments

@universse
Copy link

Hi, TypeSript is throw missing type error with the above config.

Could not find a declaration file for module 'hono'. '.../[email protected]/node_modules/hono/dist/cjs/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/hono` if it exists or add a new declaration (.d.ts) file containing `declare module 'hono';`ts(7016)

Related: microsoft/TypeScript#49160

@yusukebe
Copy link
Member

Hi @universse !

Thank you for creating the issue. I'll investigate to solve it.

@yusukebe
Copy link
Member

@universse

It's been fixed and we've released the new version including this patch.

https://github.com/honojs/hono/releases/tag/v2.5.3

Please try it and feel free to reopen the issue.

@koistya
Copy link

koistya commented Dec 26, 2022

@yusukebe "moduleResolution": "NodeNext" (or, "NodeNext") doesn't seem to work with 2.6.x, here:

https://github.com/kriasoft/react-starter-kitedge/tsconfig.json, edge/package.json, yarn workspace edge build

@yusukebe yusukebe reopened this Dec 26, 2022
@yusukebe
Copy link
Member

Hi @koistya !

I've tried it, but that does not throw the errors. I did:

  1. Edit edge/tscondig.json. Added "moduleResolution": "NodeNext"
  2. Update Hono to 2.6.2.
  3. yarn workspace edge build

Did I do it wrong?

@koistya
Copy link

koistya commented Dec 26, 2022

@yusukebe run yarn tsc --build or, open edge/index.ts — VS Code is not be able to load types from "hono".

yarn tsc --build

edge/index.ts:17:19 - error TS7006: Parameter 'ctx' implicitly has an 'any' type.

17 app.get("/echo", (ctx) => {
                     ~~~

edge/index.ts:27:23 - error TS7031: Binding element 'req' implicitly has an 'any' type.

27 app.get("*", async ({ req, executionCtx, env }) => {
                         ~~~

edge/index.ts:27:28 - error TS7031: Binding element 'executionCtx' implicitly has an 'any' type.

27 app.get("*", async ({ req, executionCtx, env }) => {
                              ~~~~~~~~~~~~

edge/index.ts:27:42 - error TS7031: Binding element 'env' implicitly has an 'any' type.

27 app.get("*", async ({ req, executionCtx, env }) => {
                                            ~~~


Found 4 errors.

But when you set "moduleResolution": "Node" in edge/tsconfig.json, this issue is no longer present.

@yusukebe
Copy link
Member

Thank you. Reproduced. I'll investigate.

@yusukebe
Copy link
Member

@koistya

This has been fixed #747 by @taishinaritomi . Thank you for creating the issue, and thanks @taishinaritomi for a lot work .
I'll release the new including this fix.

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 a pull request may close this issue.

3 participants