Skip to content

How to generate correct prop types when the prop-types package is not explicitly imported? #595

Open
@binomialstew

Description

@binomialstew

Is there a recommended way to generate prop types when the prop-types package is not explicitly imported into each component? For example, in my project, PropTypes is provided as a global through webpack's providePlugin:

config: {
    plugins: [
        new ProvidePlugin({
               PropTypes: 'prop-types',
        }),
    ]
};

So PropTypes is available to any react component—even when it is not imported.

I see the resolveToModule util looks for the prop-types import, and if it is not found, we end up with custom prop types rather than their actual type, like string or bool. It seems I can create a handler to generate prop types even when the prop-types package is not explicitly imported, but is there an already existing handler or other way to do this that addresses this case?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions