Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS2769: No overload matches this call in PDFDownloadLink #3012

Open
islam-kamel opened this issue Dec 29, 2024 · 1 comment · May be fixed by #3014
Open

TS2769: No overload matches this call in PDFDownloadLink #3012

islam-kamel opened this issue Dec 29, 2024 · 1 comment · May be fixed by #3014

Comments

@islam-kamel
Copy link

Describe the bug
Encountering a TypeScript error TS2769: No overload matches this call when using PDFDownloadLink. The error suggests that the provided ({loading}: { loading: any; }) => Element is not assignable to the expected type ReactNode | ReactElement<BlobProviderParams, string | JSXElementConstructor<any>>.

To Reproduce
Steps to reproduce the behavior:

  1. Use PDFDownloadLink with the following setup:

    import { PDFDownloadLink } from '@react-pdf/renderer';
    
    const MyDocument = () => (
      <Document>
        <Page>
          <Text>Hello, world!</Text>
        </Page>
      </Document>
    );
    
    const DownloadLink = () => (
      <PDFDownloadLink document={<MyDocument />} fileName="example.pdf">
        {({ loading }) => (loading ? 'Loading...' : 'Download PDF')}
      </PDFDownloadLink>
    );
  2. Run tsc or start the application.

  3. Observe the TypeScript error:

    TS2769: No overload matches this call.
    Overload 1 of 2,
    (props: PDFDownloadLinkProps | Readonly<PDFDownloadLinkProps>): PDFDownloadLink,
    gave the following error.
    Type ({loading}: { loading: any; }) => Element is not assignable to type
    ReactNode | ReactElement<BlobProviderParams, string | JSXElementConstructor<any>>.
    Overload 2 of 2,
    (props: PDFDownloadLinkProps, context: any): PDFDownloadLink,
    gave the following error.
    Type ({loading}: { loading: any; }) => Element is not assignable to type
    ReactNode | ReactElement<BlobProviderParams, string | JSXElementConstructor<any>>.
    

Expected behavior
The PDFDownloadLink should correctly accept the child render function and render "Loading..." while the document is being prepared or "Download PDF" when ready.

Screenshots
image

Desktop (please complete the following information):

  • OS: [Windows]
  • Browser: [Edge]
  • React-pdf version: [4.1.6]
  • TypeScript version: [5.6.2]
@islam-kamel
Copy link
Author

@diegomura Please Check This PR #3014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant