html2pdf.js icon indicating copy to clipboard operation
html2pdf.js copied to clipboard

Could not find a declaration file for module 'html2pdf.js'.

Open ValentineSean opened this issue 3 years ago • 6 comments

I want to use html2pdf.js to export html table to pdf in Vue 2 and got the error Could not find a declaration file for module 'html2pdf.js'. after importing like import html2pdf from "html2pdf.js". I have "html2pdf.js": "^0.10.1", in my package.json dependencies. I also tried import * as html2pdf from "html2pdf.js" but still got the same error. How can I solve this issue.

ValentineSean avatar Apr 06 '22 10:04 ValentineSean

I am having same issue did you resolve it?

drcoxpediant avatar Apr 16 '22 03:04 drcoxpediant

I am having same issue did you resolve it?

My error was only displaying after I hover on "html2pdf.js" in the import statement but not in the console, so I proceeded to implementation and so far its is working as expected in MS Edge but in Firefox the behavior is a bit different.

ValentineSean avatar Apr 16 '22 03:04 ValentineSean

The way that I had to fix it was like this (I dont know why yet) import html2pdf from 'html2pdf.js/dist/html2pdf.bundle';

and I had to add to my webpack.config.js

node: {
      fs: 'empty'
  },

drcoxpediant avatar Apr 16 '22 04:04 drcoxpediant

Create a file with d.ts(html2pdf.js.d.ts) and add the following code declare module 'html2pdf.js'; and it works

Preethi0395 avatar Jul 13 '23 09:07 Preethi0395

Do you fix this question?

EOMZON avatar Apr 10 '24 08:04 EOMZON