-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 builder components helpers to ts #15564
Conversation
QA Wolf here! As you write new code it's important that your test coverage is keeping up. |
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.
Everything looks grand, just some minor comments some of the optional function parameters.
BUG
- when dragging a new component to the screen I get
TypeError: Cannot read properties of null (reading '_children')
return searchComponentTree(rootComponent, comp => comp._component === type) | ||
} | ||
|
||
/** | ||
* Recursively searches for the parent component of a specific component ID | ||
*/ | ||
export const findComponentParent = (rootComponent, id, parentComponent) => { | ||
export const findComponentParent = ( | ||
rootComponent: Component | undefined, |
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.
Could these all be set as optional?
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.
rootComponent and id shouldn't be optional (or even allowed to be undefined) but it's just because the code that calls this probably isn't all TS - so we can't guarantee that we're not passing in something undefined by mistake. The 3rd param is optional, since it's intended to be blank when called externally, but it's used when it invokes itself via recursion.
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.
As @aptkingston mentioned this is reflecting the current usages... Most of them should not be nullable, but until everything is fully typed will not be safe to refactor
export const findComponentPath = (rootComponent, id, path = []) => { | ||
export const findComponentPath = ( | ||
rootComponent: Component, | ||
id: string | undefined, |
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.
Same here, an optional string for the id param instead of string | undefined
componentId, | ||
selector | ||
rootComponent: Component, | ||
componentId: string | undefined, |
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.
Possible optional value
@@ -1,3 +1,5 @@ | |||
// TODO: analise and fix all the undefined ! and ? |
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.
🥚 Just checking if this was intentionally left in
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.
Yes, this was left intentionally as it will require a much bigger refactor
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.
Conversion looks good but just a query about the types 👍
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.
LGTM!
Description
Convert builder components helpers to ts