react-split-pane icon indicating copy to clipboard operation
react-split-pane copied to clipboard

Typescript warning with React 18 types

Open michaeltford opened this issue 2 years ago • 9 comments

Describe the bug

When using with @types/react": "^18.0.15 a typescript warning is produced.

This is easily resolved by adding to the Props definition.

children: React.ReactNode; // 👈️ added type for children

michaeltford avatar Aug 03 '22 18:08 michaeltford

It would help if you included the actual warning. I assuming its the same thing I'm getting:

Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<SplitPane> & Pick<Readonly<Props>, never> & InexactPartial<...> & InexactPartial<...>'.

Although that is an error, not a warning (not sure Typescript even has warnings).

Timmmm avatar Aug 04 '22 09:08 Timmmm

Is there any workaround for this?

johnflux avatar Aug 04 '22 20:08 johnflux

@Timmmm . Yes, that's the message and you are correct that it's an error. I fixed this by forking and adding

children: React.ReactNode;

to SplitPaneProps in index.d.ts.

@johnflux I don't know of any workarounds but you could ignore using the react syntax below. (Note - it's 2 lines and will then ignore ALL typescript errors for SplitPane)

    {/* this lib is incompatible with react18. To fix     // children: React.ReactNode; needs to be added to SplitPaneProps.
     // @ts-ignore TS2322 */}
    <SplitPane>

michaeltford avatar Aug 04 '22 20:08 michaeltford

Yeah I also just used {/* @ts-ignore */}.

Timmmm avatar Aug 04 '22 21:08 Timmmm

Faced with the same issue, here is an example that I've found https://codesandbox.io/s/wr0gf

yhusynin avatar Aug 08 '22 15:08 yhusynin

Here's the react 18 doc reference, children has to be added explicitly to props: https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html#updates-to-typescript-definitions

dturcotte avatar Aug 30 '22 19:08 dturcotte

So nobody is going to fix this small issue ?

HristoP96 avatar Nov 07 '23 14:11 HristoP96