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

TypeDefinitions for PluginMoreMenuItem (and all Plugin*MenuItem) components do not include children #67091

Open
2 of 6 tasks
joshualip-plaudit opened this issue Nov 18, 2024 · 5 comments
Labels
[Type] Bug An existing feature does not function as intended

Comments

@joshualip-plaudit
Copy link

Description

Trying to build a plugin that adds an item to the "More" menu via the PluginMoreMenuItem component using versions of the editor package that export their own type definitions for the components sub-package (14.11.0 and higher) results in the error: Property 'children' does not exist on type 'IntrinsicAttributes & { href?: string | undefined; icon?: any; onClick?: Function | undefined; other?: any[] | undefined; }'.

The error is caused by the JSDoc for PluginMoreMenuItem (and the other Plugin*MenuItem components) missing the * @param {Element} props.children Children to be rendered line included in the Plugin* components that are not MenuItems (I copied that line specifically from PluginPostPublishPanel).

Step-by-step reproduction instructions

  1. Create a plugin that uses the provided code snippet
  2. Attempt to build it against version 14.11.0 or higher of "@wordpress/editor"

Screenshots, screen recording, code snippet

import {PluginMoreMenuItem} from "@wordpress/editor";
import {__} from "@wordpress/i18n";
import {removeBug} from "@wordpress/icons";
import React from "react";

registerPlugin('demo-unbuildable-plugin', {
	render() {
		return <PluginMoreMenuItem icon={removeBug} onClick={() => console.log("This is irrelevant to the error")}>{__("Some Localized Text")}</PluginMoreMenuItem>;
	}
});

Environment info

The issue is with the build process, so plugins, WP version, etc aren't relevant. The only relevant version is "@wordpress/editor", which must be version 14.11.0 or higher.

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure
@joshualip-plaudit joshualip-plaudit added the [Type] Bug An existing feature does not function as intended label Nov 18, 2024
@Mayank-Tripathi32
Copy link
Contributor

Hello @joshualip-plaudit ,

I attempted to replicate the issue using the code snippet you provided but was unable to reproduce it.
Could you please share a screencast demonstrating the problem and provide additional details to help us better understand the issue?

Looking forward to collaborating and resolving this together!

Thanks

@joshualip-plaudit
Copy link
Author

@Mayank-Tripathi32 Did you run the build process via wp-scripts build? I forgot to mention that I have it configured to actually type-check what it's building (the babel preset used in wp-scripts drops types rather than checking them).

The screenshot shows the outcome of using the wp-scripts build command first and tsc second. The tsc command identifies that the children property is undefined, which is the issue that I'm encountering.

Image

@manzoorwanijk
Copy link
Member

#67196 should fix it.

@joshualip-plaudit
Copy link
Author

@manzoorwanijk Thank you!

@manzoorwanijk
Copy link
Member

This can be closed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

3 participants