Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find a declaration file for module 'alias-hq'. #75

Open
lighth7015 opened this issue Feb 24, 2024 · 2 comments
Open

Could not find a declaration file for module 'alias-hq'. #75

lighth7015 opened this issue Feb 24, 2024 · 2 comments

Comments

@lighth7015
Copy link

Hi, when trying to use this with a SolidJS project, I'm receiving the following typescript error-

'/node_modules/alias-hq/src/index.js' implicitly has an 'any' type.
  There are types at '/node_modules/alias-hq/types/index.d.ts', but this result could not be resolved when respecting package.json "exports".
The 'alias-hq' library may need to update its package.json or typings.ts(7016)
@davestewart
Copy link
Owner

Hmm, thanks.

Could you provide a reproduction, or just the code you're using to implement Alias HQ in Solid?

@pinge
Copy link

pinge commented Jul 17, 2024

@davestewart you just need to import the package to get this error when using TypeScript (example below with VS Code):

Screen Shot 2024-07-17 at 2 31 51 AM

For types to work properly when using ESM import, you need to remove exports from package.json and add a main property:

diff --git a/node_modules/alias-hq/package.json b/node_modules/alias-hq/package.json
index b9e233a..17c9f15 100644
--- a/node_modules/alias-hq/package.json
+++ b/node_modules/alias-hq/package.json
@@ -3,12 +3,8 @@
   "version": "6.2.3",
   "description": "The end-to-end solution for configuring, refactoring, maintaining and using path aliases",
   "bin": "bin/alias-hq",
-  "exports": {
-    ".": "./src/index.js",
-    "./init": "./src/plugins/module-alias/init.js",
-    "./package.json": "./package.json"
-  },
   "types": "types",
+  "main": "./src/index.js",
   "files": [
     "src/*",
     "cli/*",
npx patch-package alias-hq --exclude 'nothing'

(--exclude 'nothing' is required when patching package.json)

A better solution would be to export and support types for CommonJS and ESM.

You can find a good explanation of what's going on here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants