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

Bug: settings in tsconfig.json#paths and package.json#imports conflicts #60821

Open
KostyaTretyak opened this issue Dec 19, 2024 · 0 comments
Open

Comments

@KostyaTretyak
Copy link

πŸ”Ž Search Terms

"package.json imports path"

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about this issue

⏯ Playground Link

No response

πŸ’» Code

My repository is intended to reproduce a bug that manifests when the following three settings are combined:

  1. "rootDir": "." in the tsconfig.json file, which is required only for VS Code and eslint.config.mjs;
  2. paths in the tsconfig.json file creates an alias for the path #lib/*, pointing to ./src/*;
  3. imports in the package.json file creates an alias for the path #lib/*, pointing to ./dist/*.

In such cases, TypeScript suggestions merge content from both the ./dist/* and ./src/* directories:


Image


πŸ™ Actual behavior

As you can see, file1.js, file2.js, and index.js appear at the same level as the src and test folders, which is incorrect.

πŸ™‚ Expected behavior

  1. The setting described in point 2 should take higher precedence for TypeScript over the setting in point 3.
  2. In any case, the settings in points 2 and 3 should not be merged.

Additional information about the issue

If in point 1 the setting is changed to "rootDir": "src", the bug disappears. However, in this case, you cannot use "include": ["test"] in the tsconfig.json file, which is very inconvenient. Instead, it is more practical to use the "rootDir": "src" setting in the tsconfig.build.json file.

@KostyaTretyak KostyaTretyak changed the title Bug: settings in tsconfig.json and package.json conflicts Bug: settings in tsconfig.json#paths and package.json#imports conflicts Dec 19, 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

No branches or pull requests

1 participant