question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Property pdf does not exist on <Page>. Incorrect typings

See original GitHub issue

Before you start - checklist

  • I followed instructions in documentation written for my React-PDF version
  • I have checked if this bug is not already reported
  • I have checked if an issue is not listed in Known issues
  • If I have a problem with PDF rendering, I checked if my PDF renders properly in Mozilla Firefox ^ Not Applicable

Description

Short description of the bug you encountered.

According to docs its possible to pass a pdf prop to a <Page> component to render a page from an arbitrary pdfjs.PDFDocumentProxy although typescript complains about this prop not existing.

I need this because I am trying to render pages from different pdfs together and multiple times so I don’t want duplicate Document elements parsing the same pdf

Steps to reproduce

See below

Expected behavior

Typescript shouldn’t complain about typings

Additional information

        <Page
          pageIndex={pageIndex}
          rotate={doc.representation[index].rotation}
          pdf={ref as pdfjs.PDFDocumentProxy}
        />

Environment

  • Browser (if applicable) [e.g. Chrome 57, Firefox 59]: N/A
  • React-PDF version [e.g. 3.0.4]: 5.2.0
  • React version [e.g. 16.3.0]: 17.0.2
  • Webpack version (if applicable) [e.g. 4.16.2]: 4.39.1
  • Typescript: 4.2.4

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
seanayecommented, May 10, 2021

I think this is a related but separate issue. Typescript is saying that the pdf prop doesn’t exist at all on the <Page> component, not that the prop is the incorrect type.

Property 'pdf' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Page> & Readonly<Props> & Readonly<{ children?: ReactNode; }>'.

1reaction
jljorgenson18commented, May 10, 2021

pdfjs-dist changed their types so this is sort of expected. You can import the same types like this

import { PDFDocumentProxy } from 'pdfjs-dist/types/display/api';

However, apparently types in @types/react-pdf also have some bad references that look like they need to be patched

node_modules/@types/react-pdf/dist/Document.d.ts:2:10 - error TS2305: Module '"pdfjs-dist"' has no exported member 'PDFDocumentProxy'.

2 import { PDFDocumentProxy } from 'pdfjs-dist';
           ~~~~~~~~~~~~~~~~

node_modules/@types/react-pdf/dist/Outline.d.ts:2:10 - error TS2305: Module '"pdfjs-dist"' has no exported member 'PDFTreeNode'.

2 import { PDFTreeNode } from 'pdfjs-dist';
           ~~~~~~~~~~~

node_modules/@types/react-pdf/dist/Page.d.ts:2:10 - error TS2305: Module '"pdfjs-dist"' has no exported member 'PDFPageProxy'.

2 import { PDFPageProxy as _PDFPageProxy } from 'pdfjs-dist';
           ~~~~~~~~~~~~

[5:31:33 PM] Found 3 errors. Watching for file changes.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Document and Page Typescript typings are missing a ...
As far as I can see is the issue that both Page and Document need a children property definition in PageProps and DocumentProps...
Read more >
Typescript : Property does not exist on type 'object'
Property "country" doesn't exist on type "object". Is this a correct way to loop through each object in array and compare the object...
Read more >
PDF form field properties, Adobe Acrobat
In Adobe Acrobat, how a form field behaves is determined by settings in the Properties dialog box for that individual field.
Read more >
Issues Uploading Documents: Common Errors, Causes, ...
Overview. This article will help you diagnose and resolve common issues when uploading PDFs or other document types via the DocuSign web ...
Read more >
Property does not exist on type '{}' in TypeScript
The "Property does not exist on type '{}'" error occurs when we try to access or set a property that is not contained...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found