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

feat(plugin-typescript): check workspace tsconfig.json #6175

Merged
merged 9 commits into from
Apr 10, 2024

Conversation

nmussy
Copy link
Contributor

@nmussy nmussy commented Mar 19, 2024

What's the problem this PR addresses?

Given the following monorepo setup, plugin-typescript is currently not enabled by default in the foo workspace, as it only checks that a tsconfig.json exists at the root of the project:

package.json
workspace/foo/package.json
workspace/foo/tsconfig.json

I also found the current README of plugin-typescript not to be helpful in diagnosing my issue

How did you fix it?

I've added a check to see if the current workspace had a tsconfig.json

I've also added a Configuration section to plugin-typescript/README.md, to help users find the tsEnableAutoTypes option.

Checklist

  • I have set the packages that need to be released for my changes to be effective.

    • I have only bumped @yarnpkg/plugin-typescript and @yarnpkg/cli, let me know if I should also select the other plugins/core etc.
  • I will check that all automated PR checks pass before the PR gets reviewed.

Comment on lines 30 to 31
?? xfs.existsSync(ppath.join(workspace.cwd, `tsconfig.json`))
?? xfs.existsSync(ppath.join(project.cwd, `tsconfig.json`));
Copy link
Member

@merceyz merceyz Mar 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
?? xfs.existsSync(ppath.join(workspace.cwd, `tsconfig.json`))
?? xfs.existsSync(ppath.join(project.cwd, `tsconfig.json`));
?? (xfs.existsSync(ppath.join(workspace.cwd, `tsconfig.json`))
|| xfs.existsSync(ppath.join(project.cwd, `tsconfig.json`)));

Otherwise it doesn't check the project root as well, if that's on purpose then:

Suggested change
?? xfs.existsSync(ppath.join(workspace.cwd, `tsconfig.json`))
?? xfs.existsSync(ppath.join(project.cwd, `tsconfig.json`));
?? xfs.existsSync(ppath.join(workspace.cwd, `tsconfig.json`));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, definitely a bug, it was causing #6175 (comment). I'm still not sure if I should re-introduce it though. If you're in a monorepo, and do not have a tsconfig.json in one of your workspaces, it might be safe to assume you're not using TypeScript in that specific workspace

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're in a monorepo, and do not have a tsconfig.json in one of your workspaces, it might be safe to assume you're not using TypeScript in that specific workspace

Not necessarily, this repo is an example of that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright thanks, that settles it then, it would have been an odd behavior anyway 👍

@nmussy
Copy link
Contributor Author

nmussy commented Mar 20, 2024

The integ tests should be good to go, the builds that failed did so on unrelated specs (https, import, check), and didn't fail for all versions, I don't think this was caused by my changes

Copy link
Member

@arcanis arcanis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@arcanis arcanis requested a review from merceyz March 27, 2024 10:01
@arcanis arcanis merged commit aa4029d into yarnpkg:master Apr 10, 2024
20 of 24 checks passed
@nmussy nmussy deleted the feat-plugin-typescript-workspace branch April 10, 2024 19:12
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 this pull request may close these issues.

3 participants