Skip to content

[TypeScript] Should reactHelpers functions be Type Guard or not? #9583

@SSW-SCIENTIFIC

Description

@SSW-SCIENTIFIC

I have written typings to reactHelpers (#9565) but these functions (isMuiComponent and isMuiElement) are used for type checking.
So I think it is better to declare these functions as type guard.

By implementation,

export function isMuiElement(element: any, muiNames: Array<string>)
    : element is ReactElement<P> & { type: { muiName: string } };
export function isMuiComponent<P>(element: any, muiNames: Array<string>): element is { muiName: string };

is considerable declaration (of course it looks not simple, so not good).

Is there any good type declaration for MUI element/component? or already exist? or the above functions should not be type guard (keep current, simply return boolean)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGreat for first contributions. Enable to learn the contribution process.typescript
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions