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

Add note on resolution to typeRoots documentation #3180

Closed
wants to merge 1 commit into from

Conversation

wjhsf
Copy link

@wjhsf wjhsf commented Jul 10, 2024

The default typeRoots config looks within the node_modules directory, (specifically, node_modules/@types) to resolve imports. This gives the impression that the contents of a custom typeRoots directory are treated as node_modules packages, and therefore can make use of features likepackage.json "exports" field. However, this does not seem to be the case. I couldn't find it explicitly documented anywhere, but through trial and error it seems that they are actually treated as directory modules. Hopefully, adding a note to the documentation will save some time for others looking into this.

typeRoots resolves modules as directory modules, not node_modules packages
@jakebailey
Copy link
Member

I'm not sure that's exactly how it works; @types packages can have export maps and they work. Are you sure this isn't just a bug in TS?

@wjhsf
Copy link
Author

wjhsf commented Jul 17, 2024

I'm not sure that's exactly how it works; @types packages can have export maps and they work. Are you sure this isn't just a bug in TS?

I'm not sure! I couldn't find much information on typeRoots, so this was pretty much a guess based on some old comments on GitHub issues. I'd be happy to be wrong about this!

@wjhsf wjhsf closed this Jul 17, 2024
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

Successfully merging this pull request may close these issues.

2 participants