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

clean up flow errors(#528) #549

Merged
merged 4 commits into from
Apr 13, 2019
Merged

clean up flow errors(#528) #549

merged 4 commits into from
Apr 13, 2019

Conversation

SebinSong
Copy link
Collaborator

Cleaning up the remaining flow errors
** Left the error about Gruntfile.babel.js:228:27( An error caused by flow not recognizing grunt.log('....'.bold) ) unsolved because it seems to happen only because flow can't recognize that special usage of grunt.log().

}
Object.keys(users).forEach((userKey) => {
users[userKey].socket && users[userKey].socket.destroy({ timeout: 500 })
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed it to the Object.keys() version only because it fixes the flow error even though using Object.values() is obviously simpler and cleaner.
please refer to :

@@ -152,7 +152,8 @@ describe('Full walkthrough', function () {
})

it('Should open sockets for Alice and Bob', async function () {
for (let user of Object.values(users)) {
const userList = Object.keys(users).map((userKey) => users[userKey])
for (let user of userList) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed it to the Object.keys() version only because it fixes the flow error even though using Object.values() is obviously simpler and cleaner.
please refer to :

facebook/flow#2221
https://github.com/facebook/flow/blob/master/lib/core.js#L65

const { contracts } = store.state
return Object.keys(contracts)
.filter((key) => contracts[key].type === 'GroupContract')
.map((key) => ({ groupName: state[key].groupName, contractID: key }))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed it to the Object.keys() version only because it fixes the flow error even though using Object.entries() is obviously simpler and cleaner.
please refer to :

facebook/flow#5838
https://github.com/facebook/flow/blob/master/lib/core.js#L48

Copy link
Member

Choose a reason for hiding this comment

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

Very informative comment/explanation, thank you for explaining why this was changed and linking to the appropriate Flow issue.

Can you insert a 1-line comment linking to that flow issue on line 148 explaining that? (So that any developers reading this who are tempted to rewrite it back to .entries understand why .keys is being used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you for reviewing and I will do that :)

Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

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

Nice job! 👍 Just some minor changes requested, see comments!

@@ -315,7 +315,7 @@ module.exports = (grunt) => {
break
case 'BUNDLE_END':
grunt.verbose.debug(this.nameArgs, event.code)
const outputName = watchOpts.output.file || watchOpts.output.dir
const outputName = watchOpts.output.dir;
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be as it was for a few reasons:

  1. The semi-colon violates our linter (StandardJS)
  2. Depending on whether this line points to a file or a directory, either watchOpts.output.file or watchOpts.output.dir will be defined

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok!

return events.reverse().map(e => b64ToStr(e))
if (Array.isArray(events)) {
return events.reverse().map(e => b64ToStr(e))
}
Copy link
Member

Choose a reason for hiding this comment

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

Nice, this makes sense, since theoretically there could have been an error and events could be undefined (in fact there could be an exception thrown too, and we don't handle that here...).

const { contracts } = store.state
return Object.keys(contracts)
.filter((key) => contracts[key].type === 'GroupContract')
.map((key) => ({ groupName: state[key].groupName, contractID: key }))
Copy link
Member

Choose a reason for hiding this comment

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

Very informative comment/explanation, thank you for explaining why this was changed and linking to the appropriate Flow issue.

Can you insert a 1-line comment linking to that flow issue on line 148 explaining that? (So that any developers reading this who are tempted to rewrite it back to .entries understand why .keys is being used?

console.log('transitionAfterEnter')
// Trigger/Target has opacity: 0 by default, so let's force to stay 1 after the animation finishes.
// Velocity(el, { opacity: 1 }, { duration: 0 })
el.style.opacity = 1
el.style.opacity = '1'
Copy link
Member

Choose a reason for hiding this comment

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

Is this right? Did Flow say to change this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

flowError1

Yes, this is what flow spits out about that code and it seems to be referring to this type defintion.

A possible solution that is suggested in this issue actually fixes the error but I'm afraid it could make the code verbose just to keep flow happy.
(changing it to
const elStyle: Object = el.style
elStyle.opacity = 1
)

Copy link
Member

Choose a reason for hiding this comment

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

Hmm. OK, makes sense. I guess as long as what you have here works the same it's fine! 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok!

// Use only opacity to fadeIn/Out because it's faster than
// Velocity's 'fadeIn' feature (it doesn't use display)
// Velocity(el, { opacity: 0 }, { duration: 0 })
el.style.opacity = 0
el.style.opacity = '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 question as above

Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

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

Alright, this looks good to merge now! Great job!

@taoeffect taoeffect merged commit fd0c8e6 into okTurtles:master Apr 13, 2019
@SebinSong SebinSong deleted the issue528-pullrequest-1 branch May 9, 2019 08:46
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