Faire / mjml-react

React component library to generate the HTML emails on the fly
https://www.npmjs.com/package/@faire/mjml-react
MIT License
375 stars 16 forks source link

No .d.ts declaration file found for extensions #73

Open bostrom opened 1 year ago

bostrom commented 1 year ago

Hello, I get the following error when trying to use components from the extensions subpackage.

import { MjmlHtml } from '@faire/mjml-react/extensions';

results in

Could not find a declaration file for module '@faire/mjml-react/extensions'. 
'node_modules/@faire/mjml-react/extensions.js' implicitly has an 'any' type.
If the '@faire/mjml-react' package actually exposes this module, 
try adding a new declaration (.d.ts) file containing 
`declare module '@faire/mjml-react/extensions';`

Adding the said declaration file resolves the issue, but this should probably be fixed here instead.

emmclaughlin commented 1 year ago

Thanks for pointing this out @bostrom. I believe I see the issue. The declaration file for @faire/mjml-react/extensions can't be found based on what is defined in the package.json for types field. We would just need to update the build to include a package.json to point to the correct declaration file. I believe https://github.com/Faire/mjml-react/issues/72 is caused by the same root problem. Glad you have a work around, but this is definitely on the radar to be fixed.

IanEdington commented 1 year ago

@bostrom (or anyone reading) we'd be very happy to accept a PR for a fix!

I think the best solution is to fix #71 and #72. Then doing ... from '@faire/mjml-react/extensions' is directly accessing the index(.js|.d.ts) inside /extensions

emmclaughlin commented 1 year ago

This is fixed by #77 for commonJS. #72 will fix for esm as well, but is still outstanding at this time.