middleware icon indicating copy to clipboard operation
middleware copied to clipboard

Open api typescript error

Open mandado opened this issue 2 years ago • 3 comments

Hello Guys

I'm using version 0.9.5 of @hono/zod-openapi. and I'm having that error, I tried to restart the typescript server, but the error keep appearing works perfectly when I run the server.

image

mandado avatar Dec 27 '23 18:12 mandado

Hi @mandado

That is probably not a bug. It is possible that @hono/zod-openapi and hono are referring to different hono files. Please reinstall and try again.

yusukebe avatar Dec 28 '23 08:12 yusukebe

This problem happens when I create a file like app.d.ts and includes on my tsconfig with the content:

declare module 'hono' {
  interface ContextVariableMap {
    result: string
  }
}

seems like the typescript it not extending the interface ContextVariableMap .

the solution for that is:

export * from 'hono';

declare module 'hono' {
  interface ContextVariableMap extends Record<string, string> {
    result: string
  }
}

mandado avatar Dec 28 '23 14:12 mandado

@mandado

Or how about this?

import 'hono'

declare module 'hono' {
  interface ContextVariableMap {
    result: string
  }
}

I don't think this is a problem that can be solved by changing the Hono code.

yusukebe avatar Dec 29 '23 13:12 yusukebe