eKoopmans / html2pdf.js

Client-side HTML-to-PDF rendering using pure JS.
MIT License
4.12k stars 1.39k forks source link

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

Open ValentineSean opened 2 years ago

ValentineSean commented 2 years ago

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.

drcoxpediant commented 2 years ago

I am having same issue did you resolve it?

ValentineSean commented 2 years ago

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.

drcoxpediant commented 2 years ago

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'
  },
Preethi0395 commented 1 year ago

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

EOMZON commented 6 months ago

Do you fix this question?

gabriel-logan commented 1 month ago

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

This works, but a lib with more than 4k stars without support for typescript is....