-1

I want to use "window.EyeDropper" in a (vue2 + ts) project. When I write this line of code:

console.log(window.EyeDropper);

My plugins Vetur throws an error message:Property 'EyeDropper' does not exist on type 'Window & typeof globalThis'.

How can I modify the code to make it correct?

XiaoMan
  • 35
  • 6

1 Answers1

1

Create and/or add to src/globals.d.ts:

declare global {
  interface Window {
    EyeDropper?: any;
  }
}
yoduh
  • 7,074
  • 2
  • 11
  • 21
  • Thank you for your help. :) But I still have some questions, whether can you help me? When I code `new EyeDropper()`, I receive a new error message"Cannot find name 'EyeDropper'. Did you mean 'eyeDropper'? -Vetur". Do you know how to deal with this? – XiaoMan Aug 31 '22 at 07:43
  • This is Document from MDN with EyeDroppper: https://developer.mozilla.org/en-US/docs/Web/API/EyeDropper – XiaoMan Aug 31 '22 at 07:48
  • Might be related to this one https://stackoverflow.com/a/76669995/10939108 – Yunus Emre Jul 12 '23 at 11:26