react-pdf icon indicating copy to clipboard operation
react-pdf copied to clipboard

SVG component types missing children prop

Open chathu-novade opened this issue 3 years ago • 1 comments

Describe the bug When try to use with Typescript setup for SVG component gives following error.

No overload matches this call.
  Overload 1 of 2, '(props: SVGProps | Readonly<SVGProps>): Svg', gave the following error.
    Type '{ children: Element; viewBox: string; style: Style; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Svg> & Readonly<SVGProps>'.
      Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Svg> & Readonly<SVGProps>'.

To Reproduce Steps to reproduce the behavior including code snippet (if applies):

  1. Create Typscript project.
  2. Try to create a Document with SVG component.

Expected behavior SVG component should be able to have props.

Desktop (please complete the following information):

  • OS: [MacOS]
  • React-pdf version: "2.3.0",

chathu-novade avatar Aug 05 '22 11:08 chathu-novade

The same also holds true for the G component. A possible solution would be to add the prop "children?: React.ReactNode" somewhere in the type definition similar to #1811

RingoDev avatar Aug 18 '22 10:08 RingoDev

Same here

dimitur2204 avatar Nov 19 '22 16:11 dimitur2204

Still open as of "@react-pdf/renderer": "^3.0.2" right?

MBeggiato avatar Jan 09 '23 12:01 MBeggiato

Still open as of "@react-pdf/renderer": "^3.0.2" right?

@MBeggiato At least the issue from this branch https://github.com/diegomura/react-pdf/pull/2087 is still not fixed

dimitur2204 avatar Jan 09 '23 12:01 dimitur2204

I suppose this is due to a React 18 requirement, right ?

Is there any workaround available other than downgrading back to 17 ?

bogdan-calapod avatar Jan 11 '23 06:01 bogdan-calapod

I suppose this is due to a React 18 requirement, right ?

@bogdan-calapod Probably!

Is there any workaround available other than downgrading back to 17 ?

You can do declare module '@react-pdf/renderer' which will ignore all types and you won't have typings

dimitur2204 avatar Jan 11 '23 08:01 dimitur2204