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

Possibly incorrect module resolution? #54

Open
jasonkuhrt opened this issue Sep 6, 2024 · 1 comment
Open

Possibly incorrect module resolution? #54

jasonkuhrt opened this issue Sep 6, 2024 · 1 comment

Comments

@jasonkuhrt
Copy link

jasonkuhrt commented Sep 6, 2024

In a Vitepress project I am seeing the following behaviour.

Given a code block like:

CleanShot 2024-09-06 at 18 08 57@2x

And given this file system in current working directory:

node_modules/
  bar/
    index.d.ts (contains: export declare const foo: number)
bar/
  index.d.ts (contains: export declare const foo2: number)

Then twoslash attempts to resolve the bar import to from ./bar instead of ./node_modules/bar.

CleanShot 2024-09-06 at 18 11 08@2x

If I rm -rf bar then node_modules/bar is used.

I think it might be an error that an import for bar would pick up ./bar before first looking for node_modules/bar.

When I run this in GitHub Actions, this problem does not happen. I am not sure why yet.

@jasonkuhrt
Copy link
Author

It's not just about index either. The same issue happens for e.g. import {...} from 'foo/x. In that case instead of looking at the exports field of node_modules/foo/package.json it will use ./foo/x.ts (.d.ts, .ts, doesn't matter) if such a file exists.

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

1 participant