Skip to content

type declaration - fix missing children prop#819

Merged
tomkp merged 2 commits intotomkp:masterfrom
ellanan:patch-1
Aug 22, 2022
Merged

type declaration - fix missing children prop#819
tomkp merged 2 commits intotomkp:masterfrom
ellanan:patch-1

Conversation

@ellanan
Copy link
Copy Markdown
Contributor

@ellanan ellanan commented May 25, 2022

React 18's types are more strict and the missing children prop results in this typescript error being thrown when using the component

Type '{ children: Element[]; css: SerializedStyles; split: "vertical"; minSize: number; maxSize: number; onDragStarted: () => void; onDragFinished: (newSize: number) => void; size: number; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<SplitPane> & { css?: Interpolation<Theme>; } & Pick<...> & InexactPartial<...> & InexactPartial<...>'.
  Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<SplitPane> & { css?: Interpolation<Theme>; } & Pick<...> & InexactPartial<...> & InexactPartial<...>'.ts(2322)

(anyone else running into this can use patch-package to modify node_modules/react-split-pane/index.d.ts in the meantime)

React 18's types are more strict and the missing `children` prop results in this typescript error being thrown when using the component

```
Type '{ children: Element[]; css: SerializedStyles; split: "vertical"; minSize: number; maxSize: number; onDragStarted: () => void; onDragFinished: (newSize: number) => void; size: number; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<SplitPane> & { css?: Interpolation<Theme>; } & Pick<...> & InexactPartial<...> & InexactPartial<...>'.
  Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<SplitPane> & { css?: Interpolation<Theme>; } & Pick<...> & InexactPartial<...> & InexactPartial<...>'.ts(2322)
```
@ellanan ellanan changed the title fix missing children prop type declaration - fix missing children prop May 25, 2022
@joriewong
Copy link
Copy Markdown

@ellanan FYI,

  • optional children refer PropsWithChildren
  • update peerDependencies

@ellanan
Copy link
Copy Markdown
Contributor Author

ellanan commented May 27, 2022

Updated to make the children prop optional!

Since the library still works with react version 16 and 17, would it make sense to keep the peerDependencies at ^16.0.0-0?

@joriewong
Copy link
Copy Markdown

joriewong commented May 27, 2022

already works with react 18.x

@giscafer
Copy link
Copy Markdown

@kelvinkoko
Copy link
Copy Markdown

👍 i hope this PR can merge soon

@giscafer
Copy link
Copy Markdown

giscafer commented Jun 30, 2022

@kelvinkoko
use react-reflex instead

@hockor
Copy link
Copy Markdown

hockor commented Jul 27, 2022

i hope this PR can merge soon~

@tomkp tomkp merged commit 49c6d36 into tomkp:master Aug 22, 2022
@marefati110
Copy link
Copy Markdown

Finally

@decpk
Copy link
Copy Markdown

decpk commented Oct 23, 2022

I'm still getting this error. Since this is merge then why it is showing this error
image

@ellanan ellanan deleted the patch-1 branch October 23, 2022 21:53
@AndrewDorne
Copy link
Copy Markdown

It looks like there hasn't been a release since this patch. Could one of the maintainers publish a new release? Thanks!

@rahulbarwalfluxon
Copy link
Copy Markdown

Please publish this.

@Seventysevendays
Copy link
Copy Markdown

still not release?

@selenehyun
Copy link
Copy Markdown

selenehyun commented May 4, 2023

I also ran into the issue of missing children types after upgrading to React 18.
So, I took a temporary measure like the following and will wait until the PR's changes are published to NPM.

If you just want to bypass the type issue while using React 18, you can create the d.ts file below:

// my-project/types/split-pane.d.ts
declare module 'react-split-pane' {
  declare class SplitPane extends React.Component<
    SplitPaneProps & {
      children?: ReactNode;
    },
    SplitPaneState
  > {}

  export default SplitPane;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.