hebcal/hebcal-es6

TypeScript type declaration error

Closed this issue · 9 comments

I am encountering a TypeScript type declaration error in my React TypeScript project when using the package. Although the package includes type declarations (hebcal.d.ts), TypeScript fails to recognize them.

The error message I receive is as follows:

Could not find a declaration file for module '@hebcal/core'. '../node_modules/@hebcal/core/dist/index.mjs' implicitly has an 'any' type. There are types at '../node_modules/@hebcal/core/hebcal.d.ts', but this result could not be resolved when respecting package.json "exports". The '@hebcal/core' library may need to update its package.json or typings.

Interestingly, when I remove the following lines from the package.json of the package:

"exports": { 
    "import": "./dist/index.mjs",
    "require": "./dist/index.js"
  },

The error is resolved. However, my concern is that when I deploy my project to platforms like Vercel or Netlify, I am unable to access and modify the package.json file to fix the issue.

Thanks for the bug report. Looks like this feature of package.json is still experimental. We removed it from @hebcal/core@4.4.0 and hopefully this should fix the issue for you.

It seems like everything is functioning properly now. Thank you!

I am still running into the same issue with the latest version of @hebcal/core I see the exports is back in the package.json but I am on version 5.0.5

Can you post the minimum React package configuration needed to reproduce the error? There are dozens of packages that use exports, and we would like ours to both follow best practices and be compatible with modern React toolchain.

I am not using react just a simple bun project, here is a minimal reproduction, in vsCode I am getting an error in index.ts
https://github.com/isaacfink/hebcal-types
image

I also tried installing with npm without any luck so it's not a bun issue

This is the tsconfig.json

{
  "compilerOptions": {
    "lib": ["ESNext"],
    "module": "esnext",
    "target": "esnext",
    "moduleResolution": "bundler",
    "moduleDetection": "force",
    "allowImportingTsExtensions": true,
    "noEmit": true,
    "composite": true,
    "strict": true,
    "downlevelIteration": true,
    "skipLibCheck": true,
    "jsx": "preserve",
    "allowSyntheticDefaultImports": true,
    "forceConsistentCasingInFileNames": true,
    "allowJs": true,
    "types": [
      "bun-types" // add Bun global
    ]
  }
}

I see now changin moduleResolution to Node fixes it

Thanks for the helpful small repo. It was super useful to help reproduce and fix the problem.

We think we've got it fixed now in v5.0.6 (even with your original "moduleResolution": "bundler")