-
Notifications
You must be signed in to change notification settings - Fork 393
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 Home page to use TypeScript #3124
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import React from 'react'; | ||
import FlatButton from 'material-ui/FlatButton'; | ||
import { connect } from 'react-redux'; | ||
import PropTypes from 'prop-types'; | ||
import styled from 'styled-components'; | ||
import { ButtonsDiv } from './Styled'; | ||
import config from '../../config'; | ||
|
||
import { HomePageProps } from './Home'; | ||
|
||
const StyledDiv = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
|
@@ -34,11 +35,11 @@ const StyledDiv = styled.div` | |
} | ||
`; | ||
|
||
const Sponsors = ({ strings }) => ( | ||
const Sponsors = ({ strings }: HomePageProps) => ( | ||
<StyledDiv> | ||
<div className="headline">{strings.home_sponsored_by}</div> | ||
<div className="images"> | ||
{config.VITE_ENABLE_DOTA_COACH && ( | ||
{config.VITE_ENABLE_DOTACOACH && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also fixes a typo here. |
||
<a | ||
href="https://dota-coach.com?s=OpenDota&c=main" | ||
target="_blank" | ||
|
@@ -84,11 +85,7 @@ const Sponsors = ({ strings }) => ( | |
</StyledDiv> | ||
); | ||
|
||
Sponsors.propTypes = { | ||
strings: PropTypes.shape({}), | ||
}; | ||
|
||
const mapStateToProps = (state) => ({ | ||
const mapStateToProps = (state: any) => ({ | ||
strings: state.app.strings, | ||
}); | ||
|
||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 it will be tedious to type all of the strings separately. . . we could just type it as the en-us JSON file type dict, or even just generic string dict
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.
like having a separate file only for types and importing what's needed? can you give an example please?
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 easy solution is just to type strings as {[key: string]: string} which you can share across everything that's using the strings.
Alternatively, since the en-US.json file has all the keys in it, it should be possible to tell TS to construct a type out of that. That would be nice because you'll get autocomplete/checking if there's a typo, but I'm not 100% sure how to do it.
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.
so looks like there are 3 approaches to this:
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.
@howardchung let me know what you think.
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.
Maybe since the JSON files will be flat we can use keyof to generate a union of the possible key values instead of string?
https://www.typescriptlang.org/docs/handbook/2/keyof-types.html
But we can do that in a separate change