cloudflare / cloudflare/chanfana
OpenAPI router unsafe assignment with `fromHono`
- Dominant language
- TypeScript
- Stars
- 766
- Forks
- 70
- Avg merge
- 25m
- Merged PRs (30d)
- 4
Description
I am getting a typescript error when trying to use `fromHono()`.
```
Unsafe assignment of an `any` value.eslint[@typescript-eslint/no-unsafe-assignment](https://typescript-eslint.io/rules/no-unsafe-assignment)
```
I took a look at the types and saw this:
```typescript
// src/adapters/hono.ts
export function fromHono(
router: M,
options?: RouterOptions
): M & OpenAPIRouterType & any {
const openapiRouter = new HonoOpenAPIHandler(router, options)
return new Proxy(router, {
// ...
}
}
```
Whats the reasoning for the `any` at the end of the return type? Same thing for `fromIttyRouter` as well... I'd have to disable a bunch of eslint rules for this file to get it working, but then I am losing all my type safety that I had before v2.
Contributor guide
Research direction
Start in src/adapters/hono.ts at fromHono(), then compare the corresponding fromIttyRouter types and the OpenAPIRouterType definition. Check the resulting types with the project's TypeScript and ESLint checks; done means both adapters preserve router type safety without requiring unsafe-assignment suppressions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100