My fouth PR request for Hacktoberfest

 Picking the Issue

I have spent a lot of time finding an issue that I am capable to work on this time. I feel that I am so bad at self-learning. I looked at quite a few issues and tried to work on it but I just can't understand them even I googled and tested a lot. Finally, I gave up on adding a new feather for my fourth pull request. Instead, I decided to contribute to the project mattermost which larger than my previous projects. 

The issue-16167 basically just convert all the file under a component from Javascript to Typescripts. The member of the project also provides the checklist for the migration.

  • < ] Rename the files to their associated TypeScript extensions (ie. js to tsjsx 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
Working on the issue

Firstly, I changed some all 4 files extension from js to ts, jsx to tsx. After I done that, there are a few compile errors show up. Such as:

Parameter 'props' implicitly has an 'any' type.

Property 'serverVersionOnAppLoad' does not exist on type 'Readonly<{}> & Readonly<{ children?: ReactNode; }>'.

roperty 'serverVersion' does not exist on type 'Readonly<{}>'

 After I googled the errors, I noticed that the most difference between Javascript and Typescript is that Typescript is more sensitive to the datatype. I created two interfaces to define the datatype of some variables.

interface IMyComponentProps {
    serverVersion?: string,
}

interface IMyComponentState {
    serverVersionOnAppLoad?: string,
}

then add them into the Class

export default class VersionBar extends React.PureComponent <IMyComponentProps
IMyComponentState>

Then, I changed a few variable's data-type using those interfaces. 

I delete the line import PropTypes from 'prop-types';  since typescript no longer need it.

I also changed a function's parameter type from string to string | undefined from another file because a dependency function only takes the string | undefined type. 

Sending pull request

when I sent a draft pull first to check will my code pass all the tests, I got 4 errors that from some formatting. I fixed it and set my pull request to ready for review, it passed all the tests. However, I still have no confidence that my code will actually work because I can not find where is my component (version bar) on the website. After one of the reviewers reviewed my code, I fixed some problems he mentioned, then he approved my pull request. I am still waiting for the merge after the approval. 

Comments

Popular posts from this blog

My PR for release 0.3 External Project

OSD600 Lab8

OSD600 -- Release 0.4.1 -- Choose Project and issues