adityasonel / react-animated-tree-v2

🌲 Simple to use, configurable tree view with full support for drop-in animations, react-animated-tree-v2.
https://adityasonel.github.io/react-animated-tree-v2
MIT License
11 stars 5 forks source link

Problem with typing #9

Open grazielleanna opened 1 year ago

grazielleanna commented 1 year ago

Hi!

When using the library with typescript the following error occurs: No overload matches this call. Overload 1 of 2, '(props: TreeProps | Readonly): Tree', gave the following error. Type '{ children: Element[]; content: string; type: string; canHide: true; open: true; style: { position: string; top: number; left: number; color: string; fill: string; width: string; }; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly'. Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly'. Overload 2 of 2, '(props: TreeProps, context: any): Tree', gave the following error. Type '{ children: Element[]; content: string; type: string; canHide: true; open: true; style: { position: string; top: number; left: number; color: string; fill: string; width: string; }; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly'. Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly'

This my code:

`

🚀} canHide />

`

Any solution to use typescript?

ajmeese7 commented 8 months ago

Same problem here, using version 1.0.5 on my end. Any thoughts?

Error:

No overload matches this call.
  Overload 1 of 2, '(props: TreeProps | Readonly<TreeProps>): Tree', gave the following error.
    Type '{ children: any[]; itemId: string; onItemToggle: () => Promise<void>; key: number; content: any; springConfig: (open: any) => { from: { height: number; opacity: number; transform: string; }; to: { ...; }; }; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Tree> & Readonly<TreeProps>'.
      Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Tree> & Readonly<TreeProps>'.
  Overload 2 of 2, '(props: TreeProps, context: any): Tree', gave the following error.
    Type '{ children: any[]; itemId: string; onItemToggle: () => Promise<void>; key: number; content: any; springConfig: (open: any) => { from: { height: number; opacity: number; transform: string; }; to: { ...; }; }; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Tree> & Readonly<TreeProps>'.
      Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Tree> & Readonly<TreeProps>'.ts(2769)
(alias) class Tree
import Tree

Code:

<Tree itemId={i.toString()} onItemToggle={async () => await fetchSelectedActionConnectionsAndPolicies(action)} key={i} content={action.toJSON().name} springConfig={config}>
ajmeese7 commented 7 months ago

The issue appears after upgrading from React 17 to React 18, and can be ignored until the library typing is updated, like so:

// @ts-expect-error library typing needs to be updated for React 18
<Tree ...>