ng2-pdf-viewer: 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

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 4
  • Comments: 15

Most upvoted comments

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, 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