honojs / hono

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

Comments in JSX Causing "Type 'undefined' is not assignable to type 'Child'." Error #1193

Open HeyITGuyFixIt opened 1 year ago

HeyITGuyFixIt commented 1 year ago

When I comment out any JSX HTML (using key combination Ctrl+/) in VS Code, it inserts {/* around the line */}. In most places this is fine, but it causes this error when a comment is a direct child of a div or table:

Type 'undefined' is not assignable to type 'Child'.

Example:

<div>
    <p>Any other tag</p>
    {/* This comment causes an error */}
</div>
<table>
    <thead>
        {/* This comment is okay */}
    </thead>
    <tbody>
        {/* This comment is fine */}
    </tbody>
    {/* This comment causes an error */}
</table>

Apparently {/* ... */} has a type of undefined (makes sense), but JSX div and table elements are not set up to take undefined values. The 'Child' type should probably include undefined to account for this situation. I only see this occur with div and table elements, and haven't come across any other instances of this happening.

yusukebe commented 1 year ago

Hi @HeyITGuyFixIt

I can't reproduce it. Is it a runtime error or it's thrown by your editor?