You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Missing "types" in package.json "exports" field breaks TypeScript with moduleResolution: "bundler" #325
When using @hcaptcha/react-hcaptcha@1.17.0 with TypeScript's moduleResolution: "bundler" (required for ESM projects), TypeScript cannot
resolve the type declarations.
Error
error TS7016: Could not find a declaration file for module '@hcaptcha/react-hcaptcha'.
'/node_modules/@hcaptcha/react-hcaptcha/dist/esm/index.js' implicitly has an 'any' type.
There are types at '/node_modules/@hcaptcha/react-hcaptcha/types/index.d.ts', but this result
could not be resolved when respecting package.json "exports".
Root Cause
The package.json has an exports field but doesn't include types entries:
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/index.js"
}
}
When TypeScript uses moduleResolution: "bundler", it strictly respects the exports field and requires types to be explicitly declared.SolutionAdd types to the exports field:"exports": {
".": {
"types": "./types/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/index.js"
},
"./hooks": {
"types": "./types/hooks/index.d.ts",
"import": "./dist/esm/hooks/index.jsx",
"require": "./dist/hooks/index.jsx"
}
}
Note: The types condition must come first in each export entry.Environment- @hcaptcha/react-hcaptcha: 1.17.0- TypeScript: 5.x- moduleResolution: "bundler"Related- #247
Hi @evgeniiPerov,
Thank you a lot for notifying us!
As you already have the solution outlined, we encourage you to contribute to the project with the PR created.
We appreciate all the contributions!
Alternatively, we'll handle it with the team.
Activity
zoryana94 commentedon Dec 9, 2025
Hi @evgeniiPerov,
Thank you a lot for notifying us!
As you already have the solution outlined, we encourage you to contribute to the project with the PR created.
We appreciate all the contributions!
Alternatively, we'll handle it with the team.
Best Regards,
hCaptcha Dev Team
zoryana94 commentedon Dec 9, 2025
@evgeniiPerov, thank you a lot for your contribution!
Please also check if the issue is resolved in react-hcaptcha 1.17.1
joao-imi commentedon Dec 9, 2025
Issue addressed in the commit: #326