sharp-phash icon indicating copy to clipboard operation
sharp-phash copied to clipboard

TypeScript typings

Open kachkaev opened this issue 2 years ago • 3 comments

👋 @btd! I just came across your library – looks great! WDYT of adding typescript typings so that users could avoid these errors in TS imports:

Could not find a declaration file for module 'sharp-phash'. '/path/tp/project/node_modules/.pnpm/[email protected][email protected]/node_modules/sharp-phash/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/sharp-phash` if it exists or add a new declaration (.d.ts) file containing `declare module 'sharp-phash';`ts(7016)

In the meantime, this serves as a workaround:

// @ts-expect-error -- upstream types do not exist: https://github.com/btd/sharp-phash/issues/14
import phash from "sharp-phash";
// @ts-expect-error -- upstream types do not exist: https://github.com/btd/sharp-phash/issues/14
import phashDistance from "sharp-phash/distance";

kachkaev avatar May 27 '23 19:05 kachkaev

Hi, sorry. I will not be able to add this anytime soon. But i am very open to either TS migration or addition of types if you mind.

btd avatar Jun 10 '23 12:06 btd

Cool! Shall I create a PR that adds index.d.ts? This will be a minor or a patch change (up to your preference). Refactoring everything to ts may be a bit more involved.

kachkaev avatar Jun 10 '23 12:06 kachkaev

Just create .d.ts file (one or two - depending if you want it to be similar to how tsc generate it). I will increment version when will do publish

btd avatar Jun 10 '23 14:06 btd