Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert App/ directory to use TypeScript #3125

Merged
merged 4 commits into from
Jun 2, 2024

Conversation

mehrdadrafiee
Copy link
Contributor

Please review.

As part of refactoring, this PR converts src/components/App/ directory to use TypeScript. There were some spots that I wasn't sure how to handle the types so I had to ignore them (@ts-nocheck) for now but feel free to pull down the changes and update the PR.

Since the styled-component is a bit old, I wasn't able to convert the src/components/App/GlobalStyles.jsx to TypeScript. Can be done once we upgrade to a newer version.

@@ -1,3 +1,4 @@
// @ts-nocheck
Copy link
Member

Choose a reason for hiding this comment

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

can we just apply ts-ignore to specific lines instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!


interface AppProps {
location: { [key: string]: string }
strings: { [key: string]: string }
Copy link
Member

Choose a reason for hiding this comment

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

Can we use one shared type for strings so if we figure out how to type it better later we only have one spot to update?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can use GlobalStrings in types/common directory, right?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah if that's an alias

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmmm... I think will be facing the second option mentioned here: #3124 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

OK, in the meantime can you point all the string references to one place instead of duplicating { [key: string]: string }?

Copy link
Member

Choose a reason for hiding this comment

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

Actually it's probably best to use Record<string, string> which is a builtin type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just updated the PR with the builtin type as you suggested. I can go ahead and update other instances of { [key: string]: string } in a separate PR if you approve.

thanks and sorry for late reply :)

@@ -137,7 +161,7 @@ const App = (props) => {
return () => {
window.removeEventListener('scroll', handleScroll);
};
});
}, []);
Copy link
Member

Choose a reason for hiding this comment

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

doesn't this change the behavior to only happen once?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

isn't it the expected behavior? clicking on the "back to top" button takes the user to the top of the screen and then the button disappears. user won't be able to click it multiple times.

Copy link
Member

Choose a reason for hiding this comment

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

If they scroll back down though we want to reenable it right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah that is what's happening right now. the button appears every time user scrolls 1000px from top and can be clicked to take the user to the top of the screen. to be honest I think it's best practice to have [] in the useEffect hook and if anything it should have a dependency on the scroll.

@howardchung howardchung merged commit c0d1cdc into odota:master Jun 2, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants