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

Relative paths in tsconfig extends not supported #177

Open
rmunch opened this issue Oct 18, 2024 · 4 comments
Open

Relative paths in tsconfig extends not supported #177

rmunch opened this issue Oct 18, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@rmunch
Copy link

rmunch commented Oct 18, 2024

Summary

Relative paths in the tsconfig extends field don't appear to work. If I adjust the path to be relative to the cwd, things work as expected.

Happy to open a PR if that'd be helpful. Thanks!

Reproduction steps

Adjust the extends field in a tsconfig file to use a relative path. Run Skott, and observe exceptions when reading tsconfig.

Expected result:

Actual result:

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
skott installed version? 0.35.3
Operating system? Mac
Would you consider contributing a PR? Yes
Node.js version (node -v)? v20.11.1
@rmunch rmunch added the bug Something isn't working label Oct 18, 2024
@antoine-coulon
Copy link
Owner

Hello @rmunch,

Thanks for reporting the issue!

Could you please provide me a concrete example of a not working config (the one you opened the issue for) vs the working config? Just to make sure that there is no quiproquo regarding the issue to fix (most of the time relative paths are misleading).

Thanks

@antoine-coulon
Copy link
Owner

@rmunch,

I'm not sure I understood the problem, I might be missing details, here is a working example with skott working extends from tsconfig.json using a relative path to tsconfig.alias.json

For me to be able to solve the issue I would need the configuration you're using that is all the tsconfig and what you're trying to achieve.

Capture d’écran 2024-10-22 à 22 19 52

@rmunch
Copy link
Author

rmunch commented Oct 22, 2024

Hi @antoine-coulon - with your screenshot above, if you move the tsconfig.json into a subdirectory and adjust the extends value to something like ../tsconfig.alias.json, that'll trigger the issue. So essentially, Skott assumes the path is relative to the current working directory rather than to the tsconfig file (in your example, both happen to be the same).

@antoine-coulon
Copy link
Owner

I see, in that case the outcome will probably depend on the directory where skott is run.

It should probably be documented somewhere, but currently skott is not really supporting the run from a directory where files are relying on path aliases references or definitions located in parent directories. What you describe to me seems like you're running skott from a sub-package and this sub-package references a tsconfig in a parent directory (which seems to be the root of the repository, usually where a tsconfig.base.json lives).

In the case you're describing, running skott from the root directory where path alias references live and then target the sub directory using --cwd=<dir> (to narrow the analysis to files located in <dir>) should work. In other words running skott from ../ that is in the same directory as tsconfig.alias.json should work, as there are only references starting with the cwd as a base reference (nothing goes outside): cd ../ && skott --cwd=<package>

While as I user I would expect both ways to work out of the box, having all resolution cases working with path aliases support indeed comes with a lot of edge cases and challenges. Also, some design decisions don't allow me an easy fix, but rather needing more or less a wide re-design, you can read a bit more there if you're interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants