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

Conversation

jakubnovak998
Copy link
Contributor

@jakubnovak998 jakubnovak998 commented Jul 23, 2020

Summary

  • Rename the files to their associated TypeScript extensions (ie. js to ts, jsx to tsx)
  • Update any components using those to the correct imports
  • Fix any errors generated by the TypeScript compiler. You can run make check-types to display any errors.

Ticket Link

Fixes mattermost/mattermost#13707

@hanzei hanzei requested a review from devinbinnie July 24, 2020 06:33
@hanzei hanzei added 2: Dev Review Requires review by a core commiter 3: QA Review Requires review by a QA tester labels Jul 24, 2020
@devinbinnie devinbinnie added the Work in Progress Not yet ready for review label Jul 24, 2020
@mattermost mattermost deleted a comment from hanzei Jul 29, 2020
@devinbinnie
Copy link
Member

Hey @jakubnovak998, thanks for the pull request!

It looks like there are some type-checking errors still occuring. Make sure to run make check-types before pushing up your code. Can you fix up those errors before I have a look at the PR?

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
@jakubnovak998
Copy link
Contributor Author

Hey @devinbinnie,
Thanks, I just fixed them. The PR is ready for review.

@jakubnovak998 jakubnovak998 reopened this Aug 8, 2020
@devinbinnie devinbinnie removed the Work in Progress Not yet ready for review label Aug 10, 2020
Copy link
Member

@devinbinnie devinbinnie left a 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) {
Copy link
Member

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.

Copy link
Contributor Author

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);
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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);
Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Member

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() {
Copy link
Member

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}
Copy link
Member

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
Copy link
Member

@devinbinnie devinbinnie left a 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)}
Copy link
Member

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>

Copy link
Contributor

@stevemudie stevemudie left a comment

Choose a reason for hiding this comment

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

LGTM

@stevemudie stevemudie added QA Review Done and removed 3: QA Review Requires review by a QA tester labels Aug 24, 2020
- remove type declaration from creatTeamData const
- change type of e to React.MouseEvent
- type of event problem resolve
@sudheerDev
Copy link
Contributor

@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
@mattermod
Copy link
Contributor

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

/cc @jasonblais @jfrerich

Copy link
Member

@devinbinnie devinbinnie left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @jakubnovak998!

@devinbinnie
Copy link
Member

/update-branch

…omponents/team_url'-module-and-associated-tests-to-TypeScript
@devinbinnie
Copy link
Member

@sudheerDev Can you have a look when you get some time?

Copy link
Contributor

@sudheerDev sudheerDev left a comment

Choose a reason for hiding this comment

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

LGTM

@sudheerDev sudheerDev merged commit 3afd4b4 into mattermost:master Sep 8, 2020
@sudheerDev sudheerDev added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core commiter labels Sep 8, 2020
@sudheerDev sudheerDev added this to the v5.28 milestone Sep 8, 2020
@amyblais amyblais added Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation labels Sep 8, 2020
jfrerich pushed a commit that referenced this pull request Oct 23, 2020
…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]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4: Reviews Complete All reviewers have approved the pull request Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation QA Review Done
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate 'components/create_team/components/team_url' module and associated tests to TypeScript
7 participants