-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Block Editor: Add type-checking for block editor (DOM utils only) #21362
Conversation
Size Change: +1.31 kB (0%) Total Size: 885 kB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left one suggestion. The type changes seem fine assuming the type checker is happy 🙂
Did you mean to add this to the root tsconfig.json
as well so it's typechecked as part of the main types build? I'd recommend that as well.
I didn't know this was a requirement 😬 And the fact that I didn't know has me even more concerned! |
Co-Authored-By: Jon Surrell <[email protected]>
It's mentioned here, but this does seem to indicate that it should be more prominent 🙂
The bullet list I added to #18838 may be better:
|
This approach of opting-in file by file works well with the caveat that you covered well in the description:
It's best to work from leaf packages to consumer packages in the package-by-package approach. In the file-by-file approach it's best to work from leaves in. In both cases it's because we'll need the dependencies typed before we can type the dependents. |
Yeah, in my case, I followed my previous work in #21053, which... is also wrong 😞 Following the documented process will likely yield better results! Noted as well at #21053 (comment) , it would be nice if we could have some combination of enforcement / automation around all of the various tasks associated with a new package. Depending on how that would be implemented (e.g. in response to the addition of a |
Added in 16e9a98. |
Related: #21361
Partially addresses #18838
This pull request proposes to add a minimal TypeScript configuration for the
@wordpress/block-editor
module, with the intention of progressively integrating type-checking into this very large module. As proposed, it currently includes type-checking for a single file,packages/block-editor/src/utils/dom.js
. This was used to help verify the fix in #21361.Until more packages opt in to typing, it may not be possible to add type-checking for certain files in this package. The file included here works largely because it has no dependencies. For the purposes of #21361, I tried also to include
src/components/block-list/block-wrapper.js
. However, since this file has many dependencies on other WordPress packages (which aren't necessarily typed), there were many errors. I assumed this may have to do with the fact we need to add type-checking for "leaf" packages before consumers, though I may be mistaken.Testing Instructions:
Verify types build without error:
cc @sirreal Do you think this is a reasonable way to go about starting to add type details for large packages?