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

Cannot import husky v9 with moduleResolution: "node" #1396

Open
apottere opened this issue Feb 15, 2024 · 3 comments
Open

Cannot import husky v9 with moduleResolution: "node" #1396

apottere opened this issue Feb 15, 2024 · 3 comments

Comments

@apottere
Copy link

Description

Typescript can't find types for a husky v9 import when using "moduleResolution": "node". It seems to work with "moduleResolution": "nodenext" (but that causes other issues for me.

It's unclear from the release notes whether this is intended as part of the nodejs 14/16 support drop. Feel free to close if it's expected.

Steps to Reproduce

  1. https://github.com/apottere/husky-v9-moduleresolution-node
  2. pnpm i (I also tested with npm, no difference)
  3. npx tsc -p tsconfig-nodenext.json - success
  4. npx tsc -p tsconfig-node.json
    index.ts:1:19 - error TS2307: Cannot find module 'husky' or its corresponding type declarations.
    
    1 import husky from 'husky';
                        ~~~~~~~
    
    
    Found 1 error in index.ts:1
    
    

This also confirms it's the types in the published package causing this issue with this particular moduleResolution, not some quirk of my setup: https://arethetypeswrong.github.io/?p=husky%409.0.11

Again, not sure if this is intended.

@typicode
Copy link
Owner

Thanks for the test repo.

I'm sorry I don't know. Husky doesn't do anything fancy with TS so I'm not sure why it's failing.

There's no build step so you can check directly the code, it's the one that is published.

Do you have the same issue with husky v9.0.8?

@apottere
Copy link
Author

Looks like it works in 9.0.8

@apottere
Copy link
Author

AFAICT adding "types": "index.d.mts", to the package.json gets resolution working for both, but I'm not sure if there are any drawbacks there.

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

2 participants