VadimDez/ng2-pdf-viewer

Cannot find name 'WeakKey'. version 10.2.2

diveshdobal opened this issue ยท 10 comments

Bug Report or Feature Request (mark with an x)
- [ ] Regression (a behavior that used to work and stopped working in a new release)
- [ ] Bug report -> please search issues before submitting
- [ ] Feature request
- [ ] Documentation issue or request

After updating from 9.1.5 to 10.2.2 I got error -
Error: node_modules/pdfjs-dist/types/web/text_layer_builder.d.ts:41:32 - error TS2304: Cannot find name 'WeakKey'.

41 textDivProperties: WeakMap<WeakKey, any>;

My angular version 16.2.12

any update on this, I got the same issue after updating to latest version for security update

Same here...need to update this package but can't because of this error.

I have the exact same problem. Any help appreciated.

using below libraries for viewing pdf in my application, but throwing below error.
"ng2-pdf-viewer": "^10.2.1",
"pdfjs-dist": "^4.3.136"

------------------------------------Error------------------------------------------------------------------------------------------------
Error: node_modules/ng2-pdf-viewer/node_modules/pdfjs-dist/types/web/text_layer_builder.d.ts:41:32 - error TS2304: Cannot find name 'WeakKey'.

text_layer_builder.d.ts file : line number 41 :textDivProperties: WeakMap<WeakKey, any>;


** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

Same problem here, in my case, using angular 16.2.12 :

  • error appears in every version since 10.1.0
  • used many ng2-pdf-viewer and pdfjs-dist version combinations does not seem to work either

The only solution that i have found to use it with angular 16 is downgrade to 10.0.0 and remove pdfjs-dist from package.json

On an angular 16 project, try adding;

"skipLibCheck": true,

to your tsconfig.json file.

This has fixed the issue for me on my angular 16 project.

On my Angular 17 project I found this was not necessary.

I noticed in this commit 15cba0d that the same was added to this project.

Si bien funciona utilizar

"skipLibCheck": true

no me parece la solucion correcta.

Same here.

BUT you do not want to disable the lib checking. pdfjs-dist anyway has a lot of problems, npm complains abut a high severity issue in it for a long time. It would be best to get rid of that dependency altogether in this project.

Same problem here

Same here.

BUT you do not want to disable the lib checking. pdfjs-dist anyway has a lot of problems, npm complains abut a high severity issue in it for a long time. It would be best to get rid of that dependency altogether in this project.

Why is disabling lib checking not a good idea? Can you provide some context? I'm having this same error and have been looking for a solution for a while. I can make it work if I edit the affected line and change "WeakMap" for "any", but I have no idea what this could be breaking. And besides, it seems to not be a very practical solution because I would need to do this edit every time I do an npm install from scratch.