react-socks
react-socks copied to clipboard
Typescript error with `style` prop
Here's a basic example which shows the issue: https://codesandbox.io/s/nifty-river-olt52e?file=/src/App.tsx
When we add a styles prop to a Breakpoint we get a Typescript error:
No overload matches this call.
Overload 1 of 2, '(props: Props | Readonly<Props>): Breakpoint', gave the following error.
Type '{ children: string; style: { background: string; }; sm: true; down: true; }' is not assignable to type 'Readonly<Props>'.
Property 'style' is incompatible with index signature.
Type '{ background: string; }' is not assignable to type 'ReactNode'.
Property 'background' does not exist on type 'ReactElement<any, string | JSXElementConstructor<any>> | ReactFragment | ReactPortal'.
Overload 2 of 2, '(props: Props, context: any): Breakpoint', gave the following error.
Type '{ children: string; style: { background: string; }; sm: true; down: true; }' is not assignable to type 'Readonly<Props>'.
Property 'style' is incompatible with index signature.
Type '{ background: string; }' is not assignable to type 'ReactNode'.
Property 'background' does not exist on type 'ReactElement<any, string | JSXElementConstructor<any>> | ReactFragment | ReactPortal'.ts(2769)
Essentially the problem is the [key: string]: React.ReactNode | string | boolean;
on ReactSocks.Props
One way to fix it is to change it to this:
[key: string]: React.ReactNode | React.CSSProperties | string | boolean;