html2canvas: Angular build fails when using html2canvas with await/async

Please make sure you are testing with the latest release of html2canvas. Old versions are not supported and issues reported for them will be closed.

Please follow the general troubleshooting steps first:

Bug reports:

When I run ng build to an Angular 7 application that uses html2canvas as:

const canvas = await html2canvas(el as HTMLElement, { useCORS: true });

I get the following error:

error TS2349: Cannot invoke an expression whose type lacks a call signature. Type ‘typeof import(“C:/my-app/node_modules/html2canvas/dist/types/index”)’ has no compatible call signatures.

Specifications:

  • html2canvas version tested with: 1.0.0-rc.2 - 1.0.0-rc.7
  • Browser & version:
  • Operating system: Windows 10

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 3
  • Comments: 15

Most upvoted comments

For those of us new to angular, if you’re on Angular 8 this means changing package.json "html2canvas": "1.0.0-rc.1" and then running npm i --verbose

@AdditionAddict RC1 helped me to build successfully. Thanks.

Yes, it’s definitely a problem regarding versions higher than 1.0.0-rc1. I have tested it with Angular 8 and can confirm that 1.0.0-rc.1 works, while 1.0.0-rc.2 and 1.0.0-rc.3 don’t work.