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

[RFR] Migrate ra-core to TypeScript #2508

Merged
merged 7 commits into from Nov 8, 2018
Merged

[RFR] Migrate ra-core to TypeScript #2508

merged 7 commits into from Nov 8, 2018

Conversation

djhi
Copy link
Contributor

@djhi djhi commented Nov 7, 2018

  • Fix demo apps
  • i18n related code
  • auth related code

- [x] Fix demo apps
- [ ] i18n related code
@ghost ghost changed the title [WIP] Migrate ra-core to TypeScript [RFR] Migrate ra-core to TypeScript Nov 8, 2018
Copy link
Contributor

@Kmaschta Kmaschta left a comment

Choose a reason for hiding this comment

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

Idk what I'm doing with this, but here is my vote. 🥇

Copy link
Member

@fzaninotto fzaninotto left a comment

Choose a reason for hiding this comment

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

You've started with the hardest part with these Higher Order Components, Kudos!

componentWillMount() {
this.checkAuthentication(this.props);
}

componentWillReceiveProps(nextProps) {
if (nextProps.location !== this.props.location) {
if (!isEqual(nextProps.location, this.props.location)) {
Copy link
Member

Choose a reason for hiding this comment

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

React-router's location object is never mutated, better rely on strict equality.

A location object is never mutated so you can use it in the lifecycle hooks to determine when navigation happens
(https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/api/location.md)

@@ -69,5 +70,5 @@ export class Authenticated extends Component {

export default connect(
null,
{ userCheck }
{ userCheck: userCheckAction }
Copy link
Member

Choose a reason for hiding this comment

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

Why did you rename the action creator in the import? It's cumbersome.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because TypeScript otherwise complain about shadowed variable names when we get userCheck from the props through destructuring

@@ -148,6 +163,6 @@ export default compose(
}),
connect(
mapStateToProps,
{ userCheck }
{ userCheck: userCheckAction }
Copy link
Member

Choose a reason for hiding this comment

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

same remark as above

@@ -0,0 +1,20 @@
export type I18nProvider = (locale: string) => object;
Copy link
Member

Choose a reason for hiding this comment

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

The i18nProvider may return a promise for locale change calls

@@ -20,7 +20,7 @@ describe('<NullableBooleanInput />', () => {

const MenuItemElement1 = MenuItemElements.at(0);
expect(MenuItemElement1.prop('value')).toEqual('');
expect(MenuItemElement1.childAt(0).text()).toEqual('');
expect(MenuItemElement1.children().length).toEqual(0);
Copy link
Member

Choose a reason for hiding this comment

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

that's not the same test. Why did you change it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because it does not have any children when its content is empty. Maybe related to the upgrade of enzyme adapter

@@ -68,7 +68,7 @@ describe('<SelectInput />', () => {
assert.equal(MenuItemElements.length, 3);
const MenuItemElement1 = MenuItemElements.first();
assert.equal(MenuItemElement1.prop('value'), '');
assert.equal(MenuItemElement1.childAt(0).text(), '');
assert.equal(MenuItemElement1.children().length, 0);
Copy link
Member

Choose a reason for hiding this comment

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

same remark as above

@fzaninotto fzaninotto merged commit f4bf80d into master Nov 8, 2018
@fzaninotto fzaninotto deleted the ra-core-ts branch November 8, 2018 17:59
@fzaninotto fzaninotto added this to the 2.4.2 milestone Nov 12, 2018
@nagesheiya
Copy link

nagesheiya commented Nov 15, 2018

I updated my package to 2.4.2, then unfortunately the LoginForm's input placeholder can't change.It is 'ra.auth.username' now. When package version is 2.4.1 , the LoginForm's input placeholder is 'Username'.
Is this a bug?

@djhi
Copy link
Contributor Author

djhi commented Nov 15, 2018

Please don't ask unrelated questions on pull requests.
Besides, as explained in the react-admin contributing guide, the right place to ask a "How To" question, get usage advice, or troubleshoot your own code, is StackOverFlow.

This makes your question easy to find by the core team, and the developer community. Unlike Github, StackOverFlow has great SEO, gamification, voting, and reputation. That's why we chose it, and decided to keep GitHub issues only for bugs and feature requests.

So I invite you to ask your question at:

http://stackoverflow.com/questions/tagged/react-admin

And once you get a response, please continue to hang out on the react-admin channel in StackOverflow. That way, you can help newcomers and share your expertise!

@nagesheiya
Copy link

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.

None yet

4 participants