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

Nested tsconfig file interferes with plugin #36

Closed
BrettMerri opened this issue Jul 12, 2022 · 2 comments · Fixed by #37
Closed

Nested tsconfig file interferes with plugin #36

BrettMerri opened this issue Jul 12, 2022 · 2 comments · Fixed by #37

Comments

@BrettMerri
Copy link

I'm using yarn workspaces, and in each package I have my own tsconfig that extends the root tsconfig. The issue is, this plugin doesn't seem to work properly regardless if I add the plugin to the nested tsconfig, or the root tsconfig.

Adding plugin to nested tsconfig

When adding the plugin to the nested tsconfig and using the paths option, the paths resolve differently between the plugin and the CLI.

  • Using a relative path like ./src (targeting src folder relative to nested tsconfig), the plugin doesn't work, but the CLI finds the strict files properly.
  • Using an absolute path like /nested/src, the plugin works now, but the CLI is not able to find any strict files.

The issue here, I believe, is that the way I'm invoking tsc-strict is via the yarn workspace which executes it inside the nested directory, whereas the plugin is taking the entire project into account. So the paths resolve differently.

Adding plugin to root tsconfig

To solve the above issue, I moved the plugin from the nested tsconfig to the root tsconfig instead and started invoking tsc-strict at the root instead. But the nested tsconfig still seems to be interfering. The plugin simply does not work unless the nested tsconfig is removed/renamed, even though that nested tsconfig extends the root config. Is it that the plugin doesn't properly grab the paths option from the extended tsconfig?

Also, not sure if related, but running tsc-strict, files are found but they all "pass" which is definitely wrong. When the plugin was in the nested tsconfig, it found plenty of strict mode errors. Removing/renaming the nested tsconfig does not fix this so not sure what is going on here.

@kamkry
Copy link
Collaborator

kamkry commented Jul 16, 2022

Hey, thanks for reporting the issue! The problem was caused by resolving the relative paths by using process.cwd() which in the case of the plugin was always set to /, I've already got a fix for that.

When it comes to specifying the plugin config in the root tsconfig that other configs extend, you have to keep in mind that extended configs copy properties from the root and modify it under the hood, so I would use that only if you want to specify a certain directory in every package you use. I recommend specifying it explicitly in each package though to avoid future confusions.

@kamkry kamkry linked a pull request Jul 16, 2022 that will close this issue
@ghost
Copy link

ghost commented Jul 22, 2022

Hello! I'm very keen on trying this plugin in our production codebase but I think this issue is also affecting us. Looking forward to your PR merged

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

Successfully merging a pull request may close this issue.

2 participants