WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.53k stars 4.21k forks source link

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

Open joshualip-plaudit opened 4 days ago

joshualip-plaudit commented 4 days ago

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.

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

Please confirm which theme type you used for testing.

Mayank-Tripathi32 commented 3 days ago

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 commented 2 days ago

@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 commented 1 day ago

67196 should fix it.

joshualip-plaudit commented 19 hours ago

@manzoorwanijk Thank you!