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

Issue with Hono JSX children type #6

Closed
bertez opened this issue Apr 22, 2024 · 2 comments
Closed

Issue with Hono JSX children type #6

bertez opened this issue Apr 22, 2024 · 2 comments

Comments

@bertez
Copy link
Contributor

bertez commented Apr 22, 2024

Hello, I think I have detected a typing error using hono and typed-htmx, ... when we create a component that receives the children property, if we decide to assign a type to that property (the Child type exported by hono), it causes a TypeScript error. You can see a test repo here:

https://github.com/bertez/hono-typed-htmx-children/blob/main/src/index.tsx#L11

In that same repo, on line 11 of types.d.ts, you can see a temporary solution, but I'm not sure if that's the right approach.

https://github.com/bertez/hono-typed-htmx-children/blob/main/src/types.d.ts#L11

Thank you!

@Desdaemon
Copy link
Owner

So I checked out this error and here's the relevant part:

  Types of property 'children' are incompatible.
    Type 'Child' is not assignable to type '{} | undefined'.
      Type 'null' is not assignable to type '{} | undefined'.

This can be a one-line fix in src/jsx.d.ts to accept null, as React does for children nodes.

@Desdaemon
Copy link
Owner

Closed by #7

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

No branches or pull requests

2 participants