-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[MM-20534] migrate 'components/create team/components/team url' module and associated tests to type script #5983
Conversation
…'components/create_team/components/team_url'-module-and-associated-tests-to-TypeScript
Hey @jakubnovak998, thanks for the pull request! It looks like there are some type-checking errors still occuring. Make sure to run If you have any questions or need any help, feel free to ask :) |
…'components/create_team/components/team_url'-module-and-associated-tests-to-TypeScript
…'components/create_team/components/team_url'-module-and-associated-tests-to-TypeScript
Hey @devinbinnie, |
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.
Thanks for the PR @jakubnovak998, I've added some comments for you to review.
|
||
constructor(props) { | ||
export default class TeamUrl extends React.PureComponent<Props, State> { | ||
public constructor(props: Props) { |
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.
Is there a specific reason this is public
? Usually we're not creating new instances of this component in JS/TS.
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.
No, there isn't any specific reason. I'll remove it.
teamSignup.team.type = 'O'; | ||
teamSignup.team.name = name; | ||
|
||
const {exists} = await checkIfTeamExists(name); | ||
const {exists}: any = await checkIfTeamExists(name); |
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.
This should be {exists: boolean}
instead of any
.
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.
It causes the problem that exists is not visible in if statement on 143 line and it does not exist on type ActionFunc.
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.
I think you might want to change the return type of checkIfTeamExists
in your type declaration. It could just look something like: Promise<{exists: boolean}>
.
@@ -140,7 +151,7 @@ export default class TeamUrl extends React.PureComponent { | |||
return; | |||
} | |||
|
|||
const {data, error} = await createTeam(teamSignup.team); | |||
const {data, error}: any = await createTeam(teamSignup.team); |
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.
This should be {data: Team, error: Client4Error}
instead of any
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.
It causes the same problems as exists change
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.
You can do the same thing here as above.
e.preventDefault(); | ||
e.currentTarget.select(); | ||
} | ||
|
||
render() { | ||
public render() { |
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.
Nit: This doesn't need to be public
, we're never calling it outside of the scope of this class.
@@ -261,7 +272,7 @@ export default class TeamUrl extends React.PureComponent { | |||
type='submit' | |||
bsStyle='primary' | |||
disabled={this.state.isLoading} | |||
onClick={this.submitNext} | |||
onClick={this.submitNext as any} |
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.
This shouldn't need to be declared as any
.
- solve exists, data/error is not visible and do not exist on ActionFunc - remove public from render and constructor - remove as any from button's onclick
…'components/create_team/components/team_url'-module-and-associated-tests-to-TypeScript
…'components/create_team/components/team_url'-module-and-associated-tests-to-TypeScript
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.
This is looking great, thanks again @jakubnovak998.
Just two small comments to resolve :)
@@ -261,7 +275,7 @@ export default class TeamUrl extends React.PureComponent { | |||
type='submit' | |||
bsStyle='primary' | |||
disabled={this.state.isLoading} | |||
onClick={this.submitNext} | |||
onClick={(e: any) => this.submitNext(e)} |
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.
e
here should be of type React.MouseEvent<HTMLDivElement>
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.
LGTM
- remove type declaration from creatTeamData const - change type of e to React.MouseEvent
- type of event problem resolve
@jakubnovak998 Hey there is a lint error and a type check error. Can you have a look |
- resolve lint errors - revert error type to any
This PR has been automatically labelled "stale" because it hasn't had recent activity. /cc @jasonblais @jfrerich |
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.
LGTM, thanks @jakubnovak998!
/update-branch |
…omponents/team_url'-module-and-associated-tests-to-TypeScript
@sudheerDev Can you have a look when you get some time? |
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.
LGTM
…e and associated tests to type script (#5983) * MM-20534 migrate team_url module and associated tests to TypeScript * MM-20534 fix type errors * MM-20534 add snapshot * MM-20534 corrections after test fail * MM-20534 changes: - solve exists, data/error is not visible and do not exist on ActionFunc - remove public from render and constructor - remove as any from button's onclick * MM-20534 fix test problem * MM-20534 changes after review: - remove type declaration from creatTeamData const - change type of e to React.MouseEvent * MM-20534 changes: - type of event problem resolve * MM-20534 changes: - resolve lint errors - revert error type to any Co-authored-by: Mattermod <[email protected]>
Summary
Ticket Link
Fixes mattermost/mattermost#13707