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

Cannot find name 'SVGGraphics' in api.d.ts #16772

Closed
benbro opened this issue Jul 31, 2023 · 9 comments
Closed

Cannot find name 'SVGGraphics' in api.d.ts #16772

benbro opened this issue Jul 31, 2023 · 9 comments

Comments

@benbro
Copy link
Contributor

benbro commented Jul 31, 2023

Can't compile v3.9.179 in a node.js project.

Configuration:

  • PDF.js version: v3.9.179

Steps to reproduce the problem:

  1. npm run dev in a node.js project including the pdf-dist package
Error: node_modules/pdfjs-dist/types/src/display/api.d.ts:1472:10 - error TS2304: Cannot find name 'SVGGraphics'.
1472 export { SVGGraphics };
@Snuffleupagus
Copy link
Collaborator

Duplicate of #16705

@Snuffleupagus Snuffleupagus marked this as a duplicate of #16705 Jul 31, 2023
@okomarov
Copy link

okomarov commented Aug 2, 2023

It's more likely for people to find this issue as it triggers on updates of pdf.js than
#16705. I would suggest adding the symptom/error from this issue to the other issue if you want to redirect to it.

The effect of this issue is that we won't be updating pdf.js until this symptom is fixed.

@Snuffleupagus
Copy link
Collaborator

The effect of this issue is that we won't be updating pdf.js until this symptom is fixed.

Fixing this will require that a TypeScript user, such as yourself, helps out here!

@amandesai01

This comment was marked as duplicate.

@dvdmunckhof
Copy link

I found a temporary workaround for this. I created a custom type declaration:

declare global {
    export type SVGGraphics = any;
}

@amandesai01
Copy link

I just rolled back to previous major version

@Liu-Jinshuai

This comment was marked as duplicate.

@cshaxu
Copy link

cshaxu commented Aug 29, 2023

I am blocked and cannot upgrade :( have to stick with 3.8.162.
Any updates on this? @Snuffleupagus

@Liu-Jinshuai
Copy link

If you don't care and want to solve this problem in the current new version, you can add in tsconfig.json:

{
   "compilerOptions": {
     //......
     "skipLibCheck": true,
   }
}

It should be noted that when you choose to use skipLibCheck, you give up the type safety check of the library file, which may cause runtime errors.

It does solve your problem though (so far)

If you feel unsafe or worried, you can roll back the version, such as the older "pdfjs-dist": "^2.4.456"

If you use an old version, you can use the following code to solve the error message (*.d.ts):

declare module 'pdfjs-dist' {
     var pdfjsLib: any;
     export = pdfjsLib;
}

lublak added a commit to lublak/pdfdataextract that referenced this issue Mar 19, 2024
currently the latest version of pdfjs dist doesn't work with typescript: mozilla/pdf.js#16772
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

7 participants