Vibrant-Colors / node-vibrant

🎨 Extract prominent colors from an image
MIT License
2.02k stars 108 forks source link

[NODE] Cannot find name 'HTMLImageElement' when building with TypeScript #119

Open WandersonAlves opened 3 years ago

WandersonAlves commented 3 years ago

Hello!

As said on the title, i can't build a personal typescript project using node-vibrant@3.2.1-alpha.1.

tsc output:

yarn run v1.22.5
$ tsc
node_modules/@vibrant/image/lib/index.d.ts:5:44 - error TS2304: Cannot find name 'HTMLImageElement'.

5 export declare type ImageSource = string | HTMLImageElement | Buffer;
                                             ~~~~~~~~~~~~~~~~

Found 1 error.

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

tsconfig.json:

{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "types": ["reflect-metadata", "node"],
    "outDir": "lib",
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "esModuleInterop": true,
    "inlineSourceMap": true,
    "lib": ["es2017"]
  },
  "include": ["src/**/*.ts"],
  "exclude": ["node_modules"]
}
christophersjchow commented 2 years ago

Pretty sure HTMLImageElement is part of the dom definitions. So include "dom" in the "lib" array

vdawg-git commented 2 years ago

I have the same error (its not a type error, it is a runtime error) Have you found a solution yet? :D