-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[GH-13718] Migrate rhs_card component and its tests to typescript #5351
[GH-13718] Migrate rhs_card component and its tests to typescript #5351
Conversation
enablePostIconOverride: PropTypes.bool, | ||
hasImageProxy: PropTypes.bool, |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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}>; |
There was a problem hiding this comment.
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:
Closing this PR to allow another contributor to work on it. More details are provided in a comment on the issue. |
Summary
Migrates
rhs_card
component and its related tests to TypeScriptTicket Link
Fixes mattermost/mattermost#13718