TwicPics / components

A Web component library that brings the power of TwicPics to your favorite web framework.
MIT License
53 stars 2 forks source link

Missing exported module type definition for react #69

Closed imrea closed 10 months ago

imrea commented 10 months ago

In a Remix 2 application where the root package.json type is set to module I am facing the following error when importing TwicImg:

import { TwicImg } from '@twicpics/components/react';
TS7016: Could not find a declaration file for module '@twicpics/components/react'.
'********************/node_modules/@twicpics/components/react/module.mjs' implicitly has an 'any' type.
There are types at ''********************/node_modules/@twicpics/components/react/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@twicpics/components' library may need to update its package.json or typings.

After doing some investigation it seems there is a missing exported type definition in @twicpics/components/package.json. In 0.22.3 the exports part looks like this:

...
  "exports": {
    "./style.css": "./style.css",
    "./react": {
      "require": "./react/index.js",
      "import": "./react/module.mjs"
    },
...
    "./svelte4": {
      "require": "./svelte4/index.js",
      "import": "./svelte4/module.mjs",
      "types": "./svelte4/index.d.ts"
    },
...

Adding that missing types entry like it is added for svelte4 to react seems to solve the typing issue:

...
  "exports": {
    "./style.css": "./style.css",
    "./react": {
      "require": "./react/index.js",
      "import": "./react/module.mjs",
      "types": "./react/index.d.ts"
    },
...

Could you please fix the package.json generation so that the missing .d.ts references are exported as well?

mbgspcii commented 10 months ago

Hi @imrea Thank you for opening an issue.

I'll keep you informed.

mbgspcii commented 10 months ago

Hi @imrea

Could you try version 0.23.0-beta.0 ?

It should fix your issue.

Hope it helps.

Miguel

mbgspcii commented 10 months ago

Hi @imrea

Version 0.23.0 has been released and should fix your issue.

Please let us know if you encounter any further problems.

Miguel