Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

[GH-13718] Migrate rhs_card component and its tests to typescript #5351

Conversation

abdusabri
Copy link
Contributor

Summary

Migrates rhs_card component and its related tests to TypeScript

Ticket Link

Fixes mattermost/mattermost#13718

Comment on lines +17 to +18
enablePostIconOverride: PropTypes.bool,
hasImageProxy: PropTypes.bool,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The component was already used without providing enablePostIconOverride and hasImageProxy props. Like:

const avatar = (
            <PostProfilePicture
                compactDisplay={false}
                post={selected}
                userId={selected.user_id}
            />
        );

So, had to make them optional because TypeScript was complaining about this 🙂

isBusy: PropTypes.bool,
isRHS: PropTypes.bool,
post: PropTypes.object.isRequired,
status: PropTypes.string,
user: PropTypes.object,
isBot: PropTypes.bool,
postIconOverrideURL: PropTypes.string,
userId: PropTypes.string,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was provided to the component when used in rhs_card, I've added it as optional to please the TypeScript compiler 🙂

@@ -38,7 +39,7 @@ export type PostPluginComponent = {
id: string;
pluginId: string;
type: string;
component: React.Component;
component: React.ComponentType<{post: Post}>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a react component is used like in the following code snippet:

if (pluginPostCardTypes.hasOwnProperty(postType)) {
            const PluginComponent = pluginPostCardTypes[postType].component;
            content = <PluginComponent post={selected}/>;
        }

TypeScript is looking for a type not a constructor function, so it was giving an error that the PluginComponent variable does not have any construct or call signatures. So, had to change it.

Here are couple of links for reference:

microsoft/TypeScript#28631

https://stackoverflow.com/questions/31815633/what-does-the-error-jsx-element-type-does-not-have-any-construct-or-call

@abdusabri abdusabri changed the title Gh 13718 migrate rhs card to typescript [GH-13718] Migrate rhs_card component and its tests to typescript Apr 18, 2020
@abdusabri
Copy link
Contributor Author

abdusabri commented Apr 19, 2020

Closing this PR to allow another contributor to work on it. More details are provided in a comment on the issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant