-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
no-unresolved
JS alias regression in 3.8+
#363
Comments
The aliases are resolved only if the file is included from the corresponding tsconfig.json or jsconfig.json. |
tsconfig just has a blanket
jsconfig has none of the above. I can't work out what specifically in 3.8 has changed this behaviour I've also tried adding
to my I know it's possible this could have been an unintentional feature, supporting alias resolution in JS files, but should it revert to Webpack resolution throughout ts/js files as that's what's really being done during builds? Is there a way that I can debug the resolved alias paths? |
Can you create a repro for a better context (Thanks) |
Not sure if the same issue 🤔 but I’m experiencing similar in project react-parallax-tilt. |
Mhmhm I see a lot of |
oh! @mkosir just to confirm, if you do @carlocorradini probably! it's definitely related to the same function :P but i need a minimal repro (as in glob calls, not an entire react project) to investigate regardless |
HI, I'm using NX as a monorepo tool, and I see the exact behaviour as well. NX relies on aliases in I ran |
@estiller Can you provide a repro? |
Here's a repro https://github.com/RobHannay/typescript-import-resolver-repro Version pinned to 3.7.0 which works fine. Bumping up to 3.8.3 causes the lint error in ![]() |
I'm not sure about the other issues listed here, but I investigated this one in particular, and it seems like it's potentially a problem with
The empty string doesn't match anything and the A workaround could be to change |
@pralkarz Wow thanks for your discovery/help. |
Just went through a bunch of stuff to clean out some definitely-unrelated bits of the config and have pushed that up now too. Here's the evidence of that repro: ![]() |
tinyglobby . 🤔EDIT after some more digging (disregard the above guess): Adding
true . I've compared that to how it was handled in 3.7.0, and removing the filter seems to fix the issue as well, although it makes the linting a little bit longer.
|
@pralkarz @RobHannay |
Thanks @carlocorradini, that makes sense! As I suspected then, in that we were actually relying on a bug. I know bug fixes aren't usually considered "breaking" in the traditional sense, but I wonder if this (correct) behavioural change might cause breakages for a number of people that were relying on it. Are you saying that adding |
@RobHannay Does VSCode/tsc itself complains no module resolved with your jsconfig/tsconfig settings? Yes so I think that's a bug fix for unintended behavior, but if not, we may need find out how does tsc fallback aliasing? |
Both VS Code and WebStorm happily resolve the import paths. Screen.Recording.2025-02-21.at.10.33.02.mov |
So when no matched |
Another small thing to note that I've just been looking at.
As I mentioned, in our https://code.visualstudio.com/docs/languages/jsconfig#_using-the-exclude-property Adding |
If no include and no files property are present we include everything ("**/*"). Same behavior as Typescript. Note that we apply your exclude if present |
The editor may be smart but if you compile with TSC the JS file Is not present in the outdir (can you try?) |
@RobHannay The .js file is emitted in the dist folder even though it's not present in both include and files? How is it possible?! |
My guess would be that it's imported by a |
Might be worth running tsc with Edit: And maybe |
Nice. Well I can see it's just imports as suspected:
Edit with traceResolution, full stack back to an
|
@carlocorradini Fallback to nearest |
We have two different types of issues:
What are your thoughts? 🫡 I'll try to fix this in a few days 😋 |
@JounQin See https://github.com/carlocorradini/eslint-import-resolver-typescript/tree/363 |
Since 3.8 aliases are no-longer being resolved in
.js
files.I've read a few of the issues raised about 3.8, but I think this is separate. I have tested with 3.8.3 and still face the issue.
We use aliases that are actually defined in three possible places:
Perhaps it was never intended to resolve imports from js files?
It's fine is I use relative paths with lots of
../
.We have a verbose config but the key details are:
Happy to try and create a proper repro repo. Do you have a base I can clone?
The text was updated successfully, but these errors were encountered: