hrynko / vue-pdf-embed

PDF embed component for Vue 2 and Vue 3
https://npmjs.com/package/vue-pdf-embed
MIT License
708 stars 109 forks source link

Build Error: Type 'VuePdfEmbedMethods' does not satisfy the constraint 'MethodOptions'. #72

Closed calvinkehl closed 2 years ago

calvinkehl commented 2 years ago

When I try to build my project I get the following error message:

Type 'VuePdfEmbedMethods' does not satisfy the constraint 'MethodOptions'.
  Index signature for type 'string' is missing in type 'VuePdfEmbedMethods'.

Using the latest release version.

hrynko commented 2 years ago

Hi @calvinkehl,

Could you provide more details on your environment (Vue version, etc.)?

calvinkehl commented 2 years ago

Hey @hrynko, of course! Here is a excerpt of my package.json:

"dependencies": {
    "dexie": "3.2.2",
    "ol": "6.15.1",
    "ol-layerswitcher": "3.8.3",
    "primeflex": "3.2.1",
    "primeicons": "5.0.0",
    "primevue": "3.15.0",
    "vue": "3.2.37",
    "vue-i18n": "9.1.10",
    "vue-pdf-embed": "^1.1.4",
    "vue-router": "4.1.2"
  },
  "devDependencies": {
    "@types/node": "18.0.6",
    "@vitejs/plugin-vue": "3.0.1",
    "@vue/compiler-sfc": "3.2.37",
    "typescript": "4.7.4",
    "vite": "3.0.2",
    "vite-plugin-compression": "0.5.1",
    "vite-plugin-pwa": "0.12.3",
    "vue-tsc": "0.38.9"
  }
hrynko commented 2 years ago

I haven't been able to reproduce, but I have a hunch that updating VuePdfEmbedMethods with the following might fix the issue:

import { MethodOptions } from 'vue'
...
export interface VuePdfEmbedMethods extends MethodOptions {
  print: (dpi?: number, filename?: string) => Promise<void>;
  render: () => Promise<void>;
}

I would appreciate if you could try this and prepare a PR if it works?

hrynko commented 2 years ago

Please let me know if I can assist you somehow

calvinkehl commented 2 years ago

Thanks for your help! It seems like your solution fixed the problem. As I haven't checked out the code, can you please create the PR?

hrynko commented 2 years ago

Would you maybe be available for opening a PR? It's only about updating types/vue3-pdf-embed.d.ts