solidjs-community / solid-transition-group

SolidJS components for applying animations when children elements enter or leave the DOM.
https://solid-transition-group.netlify.app
MIT License
254 stars 14 forks source link

Invalid type of children property #4

Closed bikeshedder closed 3 years ago

bikeshedder commented 3 years ago

Given the following code...

<Transition><div/></Transition>

...the TS compiler inside VSCode complains:

Type 'Element' is not assignable to type '(Element & (string | number | boolean | Node | ArrayElement | FunctionElement | null)) | undefined'.
  Type 'null' is not assignable to type '(Element & (string | number | boolean | Node | ArrayElement | FunctionElement | null)) | undefined'.ts(2322)
Transition.d.ts(16, 5): The expected type comes from property 'children' which is declared here on type 'IntrinsicAttributes & TransitionProps & { children?: Element; }'

Looking at the Transition.d.ts I found it accepting an Element rather than JSX.Element. Is this correct? When I change the TransitionProps as follows the error goes away:

-    children?: Element;
+    children?: JSX.Element;
ryansolid commented 3 years ago

Ah TypeScript.. I was trying to be explicit that it wasn't just any JSX element but one that was a DOM element. Like a div. I didn't check the TS but I was hoping narrowing would work but I guess the problem is TS doesn't realize that <div> is in fact an Element.. only that it could be an Element. I guess I should just change it and accept the Types won't be specific enough here.

bikeshedder commented 3 years ago

Cool. Thanks a lot for the 0.0.6 release! :+1: