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

Typescript build errors: TS2323 and TS2309 #2559

Closed
RaminRabani opened this issue Jan 24, 2024 · 5 comments
Closed

Typescript build errors: TS2323 and TS2309 #2559

RaminRabani opened this issue Jan 24, 2024 · 5 comments

Comments

@RaminRabani
Copy link

Describe the bug
In my TypeScript project I upgraded from "@react-pdf/renderer": "^3.1.6", to "@react-pdf/renderer": "^3.3.3", and now my build fails with a ton of the following errors

Error: node_modules/@react-pdf/renderer/index.d.ts(17,10): error TS2323: Cannot redeclare exported variable 'default'.
Error: node_modules/@react-pdf/renderer/index.d.ts(20,1): error TS2309: An export assignment cannot be used in a module with other exported elements.
Error: node_modules/@react-pdf/renderer/index.d.ts(53,9): error TS2323: Cannot redeclare exported variable 'Document'.
Error: node_modules/@react-pdf/renderer/index.d.ts(101,9): error TS2323: Cannot redeclare exported variable 'Page'.
Error: node_modules/@react-pdf/renderer/index.d.ts(125,9): error TS2323: Cannot redeclare exported variable 'View'.
Error: node_modules/@react-pdf/renderer/index.d.ts(150,9): error TS2323: Cannot redeclare exported variable 'Image'.
Error: node_modules/@react-pdf/renderer/index.d.ts(202,9): error TS2323: Cannot redeclare exported variable 'Text'.
Error: node_modules/@react-pdf/renderer/index.d.ts(263,9): error TS2323: Cannot redeclare exported variable 'Svg'.
Error: node_modules/@react-pdf/renderer/index.d.ts(276,9): error TS2323: Cannot redeclare exported variable 'Line'.
Error: node_modules/@react-pdf/renderer/index.d.ts(286,9): error TS2323: Cannot redeclare exported variable 'Polyline'.
Error: node_modules/@react-pdf/renderer/index.d.ts(299,9): error TS2323: Cannot redeclare exported variable 'Polygon'.
Error: node_modules/@react-pdf/renderer/index.d.ts(311,9): error TS2323: Cannot redeclare exported variable 'Path'.
Error: node_modules/@react-pdf/renderer/index.d.ts(338,9): error TS2323: Cannot redeclare exported variable 'Circle'.
Error: node_modules/@react-pdf/renderer/index.d.ts(352,9): error TS2323: Cannot redeclare exported variable 'Ellipse'.
Error: node_modules/@react-pdf/renderer/index.d.ts(365,9): error TS2323: Cannot redeclare exported variable 'Tspan'.
Error: node_modules/@react-pdf/renderer/index.d.ts(375,9): error TS2323: Cannot redeclare exported variable 'G'.
Error: node_modules/@react-pdf/renderer/index.d.ts(386,9): error TS2323: Cannot redeclare exported variable 'Stop'.
Error: node_modules/@react-pdf/renderer/index.d.ts(403,9): error TS2323: Cannot redeclare exported variable 'ClipPath'.
Error: node_modules/@react-pdf/renderer/index.d.ts(418,9): error TS2323: Cannot redeclare exported variable 'LinearGradient'.
Error: node_modules/@react-pdf/renderer/index.d.ts(455,9): error TS2323: Cannot redeclare exported variable 'BlobProvider'.
Error: node_modules/@react-pdf/renderer/index.d.ts(471,9): error TS2323: Cannot redeclare exported variable 'PDFViewer'.
Error: node_modules/@react-pdf/renderer/index.d.ts(492,9): error TS2323: Cannot redeclare exported variable 'PDFDownloadLink'.
Error: node_modules/@react-pdf/renderer/index.d.ts(512,9): error TS2323: Cannot redeclare exported variable 'Font'.
Error: node_modules/@react-pdf/renderer/index.d.ts(514,9): error TS2323: Cannot redeclare exported variable 'StyleSheet'.
Error: node_modules/@react-pdf/renderer/index.d.ts(518,9): error TS2323: Cannot redeclare exported variable 'version'.
Error: node_modules/@react-pdf/renderer/index.d.ts(520,9): error TS2323: Cannot redeclare exported variable 'PDFRenderer'.

There are a lot more errors like these.

I went to that file node_modules/@react-pdf/renderer/index.d.ts and the same errors are present. I tried downgrading back to version 3.1.6 but these errors are still present.

To Reproduce

  1. Upgrade "@react-pdf/renderer": "^3.3.3" in a TypeScript project
  2. Go to node_modules/@react-pdf/renderer/index.d.ts
  3. Observe the TS errors above

Expected behavior
The type errors above not to exist

Screenshots
If applicable, add screenshots to help explain your problem.

image

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: chrome
  • React-pdf version: 3.3.3 (but errors still exist if I downgrade back to 3.1.6, which was previously working fine)
@RaminRabani
Copy link
Author

Update: I realized that having "@react-pdf/renderer": "^3.1.6" with the caret ^ was the issue. Once I upgraded from 3.1.6 to 3.3.3 (which has the Typescript issues posted above), no amount of deleting my node_modules folder or yarn.lock would matter since subsequent yarn install's would then install the latest compatible version (3.3.4) because of the ^.

I removed the caret and changed back to 3.1.6: "@react-pdf/renderer": "3.1.6" (without the caret this time, ensuring 3.1.6 is actually installed), and the Typescript errors did not show up in the build.


FYI the TypeScript issues begin with @react-pdf/renderer version 3.2.0. It works fine without the TypeScript errors up until version 3.1.17. Would appreciate if this could be fixed. Thank you

@samkinkadeRP
Copy link

I had the same issue with version ^3.1.9. Downgraded to 3.1.6 without the caret with no issues.

@RaminRabani
Copy link
Author

RaminRabani commented Feb 5, 2024

@diegomura This is marked as closed but I am still seeing the same exact Typescript errors if I upgrade to the latest version 3.3.5

@jd-carroll
Copy link

@RaminRabani - Please see #2624 that is your issue

@carlospombeiro
Copy link

Adding "skipLibCheck": true in tsconfig.json worked for me.

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

No branches or pull requests

5 participants