-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
chore(gatsby): Translate redux/nodes to TypeScript #21010
Conversation
|
||
exports.addResolvedNodes = addResolvedNodes | ||
return resolvedNodes | ||
} |
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.
This function was changed to create an array and return it instead of modifying the argument array. Having an idempotent function feels better than having one with side effects. This function was only used in one place, and its usage was identical to this:
https://github.com/gatsbyjs/gatsby/pull/21010/files#diff-5d2176cb542d5c01d884139970be33fbR314
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.
Need to check this. Could be faster, actually. Could also be slower. (Consider the case where each type has 100k nodes and they get merged. Before they were pushed onto the same node array, after they are pushed in their own array and later merged through a _.flatten()
(which should really just be a .concat()
imo)).
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 checked this. It's slower, for sure, but in the case of the 150k ifsc benchmark it adds 5 to 10 seconds. I don't like slowing the build down for the user for the sake of something that only affects us at dev time, but I think the right choice is to do it anyways in this case ... :/
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 don't know if typing()
is a proper lerna thing. Probably just chore()
, but we should look into that)
(To the point of Greatly expands the coverage of types for redux state
; I think it would be good if we had a coverage report included in PRs.)
This touches perf sensitive stuff and we need to benchmark it first. Numbers will lead the way.
|
||
exports.addResolvedNodes = addResolvedNodes | ||
return resolvedNodes | ||
} |
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.
Need to check this. Could be faster, actually. Could also be slower. (Consider the case where each type has 100k nodes and they get merged. Before they were pushed onto the same node array, after they are pushed in their own array and later merged through a _.flatten()
(which should really just be a .concat()
imo)).
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.
Did a fairly thorough review. It looks good! I do have a few questions.
}, | ||
}) | ||
for (const node of nodes.values()) { | ||
const resolved = await resolver(node) |
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.
Isn't it possible that the first returned promise is actually this one? So the return value wouldn't be undefined
, but whatever resolved
is.
I'm a little surprised TS is accepting that. Maybe because Resolver
is typed as any
.
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.
Do you have any idea what it should be typed as? I don't yet know what this resolver really is.
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.
No, not when I was reviewing it. So if TS is fine with it, I guess let's just keep it like this and revisit that 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.
Let's do this! 💃
Published in [email protected] (just in case we need to bisect it) |
Description
This PR does a few things.
redux/nodes.ts