TypeScript Declaration Files Not Resolving Properly
Package Version: 0.0.4 TypeScript Version: 5.8.3 React Version: 19.1.0 Package Manager: pnpm 10.8.1
Issue Description
TypeScript cannot find declaration files for @responsive-email/react-email when importing components from the package, despite the type definitions existing in the package.
Error Message
Could not find a declaration file for module '@responsive-email/react-email'.
'/path/to/node_modules/@responsive-email/react-email/dist/index.mjs' implicitly has an 'any' type.
There are types at '/path/to/node_modules/@responsive-email/react-email/dist/index.d.ts',
but this result could not be resolved when respecting package.json "exports".
The '@responsive-email/react-email' library may need to update its package.json or typings.
Reproduction Steps
- Install the package:
pnpm install @responsive-email/react-email - Import components:
import { ResponsiveRow, ResponsiveColumn } from "@responsive-email/react-email"; - TypeScript reports it cannot find declaration files
I've also tried:
- Importing from subpaths:
import { ResponsiveRow } from "@responsive-email/react-email/responsive-row"; - Reinstalling the package
- Clearing the pnpm cache with
pnpm store prune
Can you please help me? I want to use the ResponsiveRow and ResponsiveColumn to create a mobile-responsive email with react.email.
I've managed to work around this issue by adding a declarations.d.ts file in my project with:
declare module '@responsive-email/react-email';
However, this is just hiding the TypeScript error rather than fixing the root cause. Looking at the package.json, it seems the issue might be that the "exports" field needs to include the type definitions. Something like:
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"types": "./dist/index.d.ts" // This is missing
},
"./responsive-row": {
"import": "./dist/responsive-row.mjs",
"require": "./dist/responsive-row.js",
"types": "./dist/responsive-row.d.ts" // This is missing
},
"./responsive-column": {
"import": "./dist/responsive-column.mjs",
"require": "./dist/responsive-column.js",
"types": "./dist/responsive-column.d.ts" // This is missing
}
}
I should note that without the declarations.d.ts workaround, the components still function correctly at runtime - the ResponsiveRow and ResponsiveColumn components render properly in my email templates. It's just that TypeScript shows errors during development. This suggests it's purely a TypeScript declaration resolution issue, not a functional problem with the components themselves.