-
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
Fix misc type compilation errors in editor and block editor packages #67410
Conversation
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
@@ -108,6 +108,7 @@ export { Heading as __experimentalHeading } from './heading'; | |||
export { HStack as __experimentalHStack } from './h-stack'; | |||
export { default as Icon } from './icon'; | |||
export type { IconType } from './icon'; | |||
export type { WPCompleter } from './autocomplete/types.ts'; |
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.
The WPCompleter
type is being used in block-editor/autocompleters three times, e.g.,
/** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */ |
/** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */
I was wondering whether files that import the type should be doing it at all?
In which case the JS Docs in block-editor/autocompleters
could be updated and this export removed.
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.
Hey Ramon, thank you for the ping! For future instances, using the @WordPress/gutenberg-components group handle may be better in case one of us can't reply straight away (that was me last week 😅 )
In general, we haven't really exported types from the package, so my first instinct would be to revert this change, and then consider the best course of action — which is to probably fix those type imports across Gutenberg
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.
Will do, thank you!
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.
Revert/update PR:
* @param {Object} props - The component props. | ||
* @param {React.ReactEl} props.children - The child components to render. | ||
* @param {Object} props - The component props. | ||
* @param {React.ReactNode} props.children - The child components to render. |
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.
This was probably a typo. React.ReactEl
doesn't exist
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 don't have the whole context around these changes, but do we actually need ReactNode
instead of ReactElement
? In other words, do we ever need to render children
that are null
, undefined
, boolean
, number
, string
?
Just asking in case the right choice here was ReactElement
.
If we go for ReactElement
, we could also consider updating the return type to ReactElement | null
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'm not sure, but I'm sure ReactElement is a good substitute here 👍🏻
I'll do a follow up.
Size Change: 0 B Total Size: 1.83 MB ℹ️ 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.
Thanks, @ramonjd!
a1dafb2
to
527bcb7
Compare
Thanks for testing @Mamaduka I'll merge for now. Can always follow up on the |
…ordPress#67410) Co-authored-by: ramonjd <[email protected]> Co-authored-by: Mamaduka <[email protected]>
… update types to Object for now. Use ReactElement instead of ReactNode
…67410) Co-authored-by: ramonjd <[email protected]> Co-authored-by: Mamaduka <[email protected]>
What? Why? How?
I noticed while working on #67406 there were some typing errors locally.
Some of the JS Docs type annotations weren't quite right. Updated.
Also,
WPCompleter
was used in the block editor package for autocompleters, but it wasn't exported. So I exported it YOLO style.Why?
Testing Instructions
Build should pass as expected