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

Components: Invert tsconfig to be exclude-based #43534

Merged
merged 2 commits into from
Aug 24, 2022
Merged

Conversation

mirka
Copy link
Member

@mirka mirka commented Aug 23, 2022

Related to #35744

What?

Changes the tsconfig for the components package so that it is an exclude list rather than an include list.

Why?

Currently the TypeScript data for the components package is not available outside the package itself, because we do not generate an index.d.ts in the build-types folder. To do this, we need to get to a point where src/index.js can be included in our tsconfig.json. This is a good milestone to hit in the process of working on #35744.

We don't necessarily need to manually convert all the remaining components in #35744 before we can hit this milestone, because as long as everything in the code path of src/index.js is free of TS errors, it will build. They can still be .js files, or they can be @ts-nochecked.

With this in mind, I think this is a good time to flip the tsconfig so it is an exclude list instead of an include list.

Benefits

  • All new files (outside of excluded paths) will be checked by default.
  • It immediately adds typechecking to some non-erroring paths that weren't in the include list yet.
  • It makes it easier to see what paths are left before we can reach our src/index.js milestone.

How?

Starting with a universal include, I ran npx tsc --build --watch and added excludes for paths that were erroring. Then, I made sure that all paths in the former include list were still included.

Testing Instructions

✅ The types still build

@mirka mirka added the [Package] Components /packages/components label Aug 23, 2022
@mirka mirka self-assigned this Aug 23, 2022
@mirka mirka requested a review from ajitbohra as a code owner August 23, 2022 17:49
@mirka mirka requested review from ciampo, torounit and walbo August 23, 2022 17:53
@ciampo
Copy link
Contributor

ciampo commented Aug 23, 2022

cc'ing @sirreal in case he has any wisdom to sprinkle — do you see any issues with this approach?

Copy link
Contributor

@ciampo ciampo left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

Code changes look good, and I checked on my machine that the build, build-module, build-style and build-types directories have the exact same contents before and after the tsconfig.json changes

@mirka mirka merged commit 2c8ac50 into trunk Aug 24, 2022
@mirka mirka deleted the components-ts-invert branch August 24, 2022 11:58
@github-actions github-actions bot added this to the Gutenberg 14.1 milestone Aug 24, 2022
@cbravobernal cbravobernal added the [Type] Code Quality Issues or PRs that relate to code quality label Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants