hono icon indicating copy to clipboard operation
hono copied to clipboard

Remove "children" from FC

Open usualoma opened this issue 1 year ago • 1 comments

What is the feature you are proposing?

(Due to my lack of insight) FC no longer includes children since React 18, so I would like to exclude children from hono accordingly.

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L853

diff --git a/src/jsx/index.ts b/src/jsx/index.ts
index 60b1eb1a..a1c052e7 100644
--- a/src/jsx/index.ts
+++ b/src/jsx/index.ts
@@ -273,9 +273,7 @@ export const jsxFn = (
   }
 }
 
-export type FC<T = Props> = (
-  props: T & { children?: Child }
-) => HtmlEscapedString | Promise<HtmlEscapedString>
+export type FC<T = Props> = (props: T) => HtmlEscapedString | Promise<HtmlEscapedString>
 
 const shallowEqual = (a: Props, b: Props): boolean => {
   if (a === b) {

usualoma avatar Feb 02 '24 23:02 usualoma

Hi @usualoma

It's good and how about providing PropsWithChildren like the @types/react?

type PropsWithChildren<P = unknown> = P & { children?: Child | undefined }

type Post = {
  id: number
  title: string
}

function Parent({ title, children }: PropsWithChildren<Post>) {
  return (
    <div>
      <h1>{title}</h1>
      {children}
    </div>
  )
}

yusukebe avatar Feb 03 '24 09:02 yusukebe

This was fixed by #2151. Thanks!

yusukebe avatar Feb 14 '24 08:02 yusukebe