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

Build: Simplify tsconfig.json files #68326

Merged
merged 3 commits into from
Dec 27, 2024
Merged

Build: Simplify tsconfig.json files #68326

merged 3 commits into from
Dec 27, 2024

Conversation

sirreal
Copy link
Member

@sirreal sirreal commented Dec 26, 2024

What?

Simplify tsconfig.json files. TypeScript 5.5 introduced a configDir variable that can be used for templating tsconfig.json files. This can vastly reduce repitition in tsconfig.json files.

  • Add standardized configuration to base tsconfig.json file.
  • Remove redundant configuration from package tsconfig.json files.
  • Remove redundant file globs (e.g. src instead of src/**/*).

Why?

This removes a lot of repetition from tsconfig.json files.

Testing Instructions

CI passes. TSC should continue to work as expected locally.

@sirreal sirreal added the [Type] Build Tooling Issues or PRs related to build tooling label Dec 26, 2024
@sirreal sirreal marked this pull request as ready for review December 26, 2024 17:08
Copy link

github-actions bot commented Dec 26, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: sirreal <[email protected]>
Co-authored-by: manzoorwanijk <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

);
} catch ( e ) {
console.error(
`Error parsing package.json for package ${ packageName }`
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for handling errors here.

Copy link

Flaky tests detected in 8f4b91b.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12506387253
📝 Reported issues:

@@ -1,10 +1,5 @@
{
"$schema": "https://json.schemastore.org/tsconfig.json",
Copy link
Member

@manzoorwanijk manzoorwanijk Dec 26, 2024

Choose a reason for hiding this comment

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

While we are here, why do we need this "$schema" in ever tsconfig.json file? Don't the IDEs and TS automatically infer that?

Copy link
Member

Choose a reason for hiding this comment

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

I see that it was added in #59861

Copy link
Member Author

Choose a reason for hiding this comment

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

Some might infer it based on the filename, but including it ensures that supporting environments will use the appropriate schema. There's little downside to including it and the benefits are significant.

Copy link
Member

@manzoorwanijk manzoorwanijk left a comment

Choose a reason for hiding this comment

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

This is a nice clean up. I have been thinking about this for a while. Thank you for beating me.

@sirreal sirreal merged commit ca61601 into trunk Dec 27, 2024
87 of 88 checks passed
@sirreal sirreal deleted the build/simplify-tsconfig branch December 27, 2024 07:58
@github-actions github-actions bot added this to the Gutenberg 20.0 milestone Dec 27, 2024
@manzoorwanijk
Copy link
Member

We need to fix rootDir for test/e2e/tsconfig.json because there is no src directory. I will create a PR to add a couple more improvements there.

@manzoorwanijk
Copy link
Member

I have created #68346 following this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Build Tooling Issues or PRs related to build tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants