simonwep / pickr

🎨 Flat, simple, multi-themed, responsive and hackable Color-Picker library. No dependencies, no jQuery. Compatible with all CSS Frameworks e.g. Bootstrap, Materialize. Supports alpha channel, rgba, hsla, hsva and more!
https://simonwep.github.io/pickr
MIT License
4.31k stars 285 forks source link

Fix broken type declarations #335

Closed wipeautcrafter closed 7 months ago

wipeautcrafter commented 7 months ago

Issue

When trying to import Pickr in a TypeScript project, the types add an extra .default. This means that instead of Pickr.create, TypeScript exposes Pickr.default.create.

import Pickr from '@simonwep/pickr'

const pickr = Pickr.create({
//                  ^^^^^^ Property 'create' does not exist on type (...)

Solution

Moving the types/pickr.d.ts file to index.d.ts seems to fix the problem.

wipeautcrafter commented 7 months ago

It seems this problem is instead caused by "type": "module" in package.json, and these changes were a false positive.