Repository: diegomura/react-pdf
File: packages/renderer/index.d.ts (TypeScript)

Code before:

  interface LinkProps extends NodeProps {
    /**
     * Enable/disable page wrapping for element.
     * @see https://react-pdf.org/components#page-wrapping
     */
    wrap?: boolean;
    /**
     * Enables debug mode on page bounding box.
     * @see https://react-pdf.org/advanced#debugging
     */
    debug?: boolean;
    src: string;
  }

  /**
   * A React component for displaying a hyperlink. Link’s can be nested
   * inside a Text component, or being inside any other valid primitive.
   */
  class Link extends React.Component<React.PropsWithChildren<LinkProps>> {}

  interface NoteProps extends NodeProps {
    children: string;
  }

  class Note extends React.Component<NoteProps> {}

  interface CanvasProps extends NodeProps {
    /**
     * Enables debug mode on page bounding box.
     * @see https://react-pdf.org/advanced#debugging
     */
    debug?: boolean;
    paint: (
      painter: any,
      availableWidth: number,
      availableHeight: number,
    ) => null;
  }

  class Canvas extends React.Component<React.PropsWithChildren<CanvasProps>> {}

  interface SVGProps extends NodeProps {
    /**
     * Enables debug mode on page bounding box.
     * @see https://react-pdf.org/advanced#debugging
     */
    debug?: boolean;
    width?: string | number;
    height?: string | number;
    viewBox?: string;

Review comment (suggestion):
While the current type does limit `children` to a single `string`, the error message is convoluted.
> No overload matches this call.
  Overload 1 of 2, '(props: PropsWithChildren\<NoteProps> | Readonly\<PropsWithChildren\<NoteProps>>): Note', gave the following error.
    Type 'Element' is not assignable to type 'string & ReactNode'.
      Type 'ReactElement\<any, any>' is not assignable to type 'string & ReactPortal'.
        Type 'ReactElement\<any, any>' is not assignable to type 'string'.
  Overload 2 of 2, '(props: PropsWithChildren\<NoteProps>, context: any): Note', gave the following error.
    Type 'Element' is not assignable to type 'string & ReactNode'.

vs the new error
> No overload matches this call.
  Overload 1 of 2, '(props: NoteProps | Readonly\<NoteProps>): Note', gave the following error.
    Type 'Element' is not assignable to type 'string'.
  Overload 2 of 2, '(props: NoteProps, context: any): Note', gave the following error.
    Type 'Element' is not assignable to type 'string'.

Code after:

  interface LinkProps extends NodeProps {
    /**
     * Enable/disable page wrapping for element.
     * @see https://react-pdf.org/components#page-wrapping
     */
    wrap?: boolean;
    /**
     * Enables debug mode on page bounding box.
     * @see https://react-pdf.org/advanced#debugging
     */
    debug?: boolean;
    src: string;
  }

  /**
   * A React component for displaying a hyperlink. Link’s can be nested
   * inside a Text component, or being inside any other valid primitive.
   */
  class Link extends React.Component<React.PropsWithChildren<LinkProps>> {}

  interface NoteProps extends NodeProps {
    children: string;
  }

  class Note extends React.Component<NoteProps> {}

  interface CanvasProps extends NodeProps {
    /**
     * Enables debug mode on page bounding box.
     * @see https://react-pdf.org/advanced#debugging
     */
    debug?: boolean;
    paint: (
      painter: any,
      availableWidth: number,
      availableHeight: number,
    ) => null;
  }

  class Canvas extends React.Component<CanvasProps> {}

  interface SVGProps extends NodeProps {
    /**
     * Enables debug mode on page bounding box.
     * @see https://react-pdf.org/advanced#debugging
     */
    debug?: boolean;
    width?: string | number;
    height?: string | number;
    viewBox?: string;