honojs / hono

Web framework built on Web Standards
https://hono.dev
MIT License
19.84k stars 566 forks source link

'Fragment' cannot be used as a JSX component #1402

Closed adarah closed 1 year ago

adarah commented 1 year ago

What version of Hono are you using?

3.5.7

What runtime/platform is your app running on?

None, typescript issue.

What steps can reproduce the bug?

  1. Clone https://github.com/honojs/examples
  2. cd jsx-ssr && npm i
  3. Open top.tsx, try placing a hono/jsx Fragment as such:
    
    import { Fragment } from "hono/jsx";
    import { Layout } from "../components/Layout";
    import type { Post } from "../index";

const List = (props: { post: Post }) => (

  • {props.post.title}
  • );

    export const Top = (props: { posts: Post[] }) => { return ( <Layout title={"Top"}>

    Posts

      {props.posts.map((post) => ( ))}

    Hello world

    </Layout>

    ); };

    
    
    ### What is the expected behavior?
    
    Placing Fragments inside JSX should not result in type errors.
    
    ### What do you see instead?
    
    <img width="990" alt="image" src="https://github.com/honojs/hono/assets/36046024/070d8a35-8bf4-40a6-b0e4-80625a4a3be8">
    
    Happens on vscode and vim.
    
    ### Additional information
    
    This also happens in another project of mine, but I used the examples repo for easier reproduction.
    msonnemans commented 1 year ago

    I am experiencing a similar issue.

    Hono: ^3.5.4, tsconfig: "jsx": "react-jsx", "jsxImportSource": "hono/jsx"

    'Fragment cannot be used as a JSX component. [...] Type 'JSXNode' is not assignable to type 'string'.

    yusukebe commented 1 year ago

    Hi @adarah , @msonnemans !

    This issue may be fixed with new version v3.5.8. Try it!