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

Does not handle tsconfig without baseUrl #58

Closed
2 tasks
andreww2012 opened this issue Sep 16, 2023 · 7 comments · Fixed by #59
Closed
2 tasks

Does not handle tsconfig without baseUrl #58

andreww2012 opened this issue Sep 16, 2023 · 7 comments · Fixed by #59
Labels
bug Something isn't working

Comments

@andreww2012
Copy link

andreww2012 commented Sep 16, 2023

Problem

A "continuation" of #50 😅

Nuxt 3.7.x changed the format of generated tsconfig again, which now less uses absolute paths but most importantly for some reason does not include baseUrl field. This causes get-tsconfig to resolve baseUrl to undefined and again eslint-import-resolver-typescript not to work properly.

Expected behavior

Resolved baseUrl must not be set to undefined, I guess.

Minimal reproduction URL

https://github.com/andreww2012/eslint-plugin-import-with-nuxt-3.6-false-reports

Version

v4.7.0

Node.js version

v16.20.2

Package manager

pnpm

Operating system

Windows

Contributions

  • I plan to open a pull request for this issue
  • I plan to make a financial contribution to this project
@andreww2012 andreww2012 added the bug Something isn't working label Sep 16, 2023
@privatenumber
Copy link
Owner

privatenumber commented Sep 17, 2023

Like your previous issue, your reproduction is not minimal at all.

Can you update it to demonstrate that tsc emits an error? Happy to re-open once it's minimal.

FYI This package is about TypeScript compatibility, not Nuxt.

@andreww2012
Copy link
Author

I'm sorry, but could you help me understand what needs to be changed to make it more minimal?

  • All that is required from Nuxt is to generate .nuxt/tsconfig.json file. That's it. Why I'm not including the pre-generated tsconfig? Because it may contain absolute paths.
  • My repro script is get-tsconfig.js which invokes this library's exported functions directly.
  • My 2nd another repro script lints the repo with ESLint, but this one exists just to test whether false errors are reported with the current dependencies.

Full reproduction instructions can be found in the README of that repository.

@andreww2012 andreww2012 changed the title Does not handle extended tsconfig without baseUrl Does not handle tsconfig without baseUrl Sep 17, 2023
@andreww2012
Copy link
Author

andreww2012 commented Sep 17, 2023

Actually, if resolving baseUrl to undefined if it's missing from the input tsconfig is an expected behaviour, I should probably redirect this issue directly to eslint-import-resolver-typescript. They probably don't expect baseUrl to not present since it was made optional since TypeScript 4.1 provided that paths are used (https://www.typescriptlang.org/tsconfig#baseUrl)

Edit: actually no, they only use getTsconfig and createPathsMatcher. baseUrl is not mentioned in their code, but it likely affects how createPathsMatcher is working.

@privatenumber
Copy link
Owner

What makes a reproduction minimal is that there is nothing extra. Specifically, if I can delete a file or code and still reproduce the bug, the repro is not minimal.

In contrast, your repro has 10 dependencies, 7 script commands, and over 10 files just in the root.

I work on this project for free but I'm not providing free debugging support, so it's up to the users to prove that there's a bug without creating more work. If you need closer assistance, you can consider sponsoring me for Priority Support.

@andreww2012
Copy link
Author

andreww2012 commented Sep 20, 2023

I believe that those dependencies were not affecting the output of the main reproduction script, but I fully understand & agree with you that there is always a non-zero chance that this still could be the case.

So I've updated the repo to remove all extra dependencies and cleared away all unnecessary stuff from the generated tsconfigs.

I've also created a separate branch (diff) that also includes typescript as a dependency to verify that the TS compiler resolves paths correctly.

@privatenumber
Copy link
Owner

Thanks. I added a failing test case in #58 (In the future, it may be a lot easier to open a PR with a failing test).

I don't have time to work on a fix right now but feel free to investigate why this is happening.

@andreww2012
Copy link
Author

Thank you for fixing!

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

Successfully merging a pull request may close this issue.

2 participants