ng2-pdf-viewer
ng2-pdf-viewer copied to clipboard
Cannot find name 'WeakKey'. version 10.2.2
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 https://github.com/VadimDez/ng2-pdf-viewer/commit/15cba0d603dcaec52f27cbdb89e97d3ef7cec0f6 that the same was added to this project.
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.
@mgustran provided the most accurate answer. Using the 'skipLibCheck' option didn't seem like the right approach. I found it more effective to downgrade the version, remove pdfjs-dist, and that resolved the issue.
Upgrading to Angular 17 solved it for me.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
export declare const reverseTransformCache: WeakMap<WeakKey, any>;
i also got this error and i just change WeakKey type to any and it is working but it needs to resolve because i need to manually update this line when i do npm install.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.