-
Notifications
You must be signed in to change notification settings - Fork 91
refactor(widget): improve props handling, esp for templates #6319
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
base: main
Are you sure you want to change the base?
Conversation
| if Table.isNotEmpty(self.defaultProps) then | ||
| return self.defaultProps | ||
| end |
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.
imo add a comment that this handling is only legacy and deprecated
| if prop.type == 'integer' then | ||
| args[propName] = WidgetFactory._parseInteger(args[propName]) |
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.
what about non integer numbers?
maybe
| if prop.type == 'integer' then | |
| args[propName] = WidgetFactory._parseInteger(args[propName]) | |
| if prop.type == 'integer' or prop.type == 'number' then | |
| args[propName] = WidgetFactory._parseNumber(args[propName]) |
| ---@param args {widget: string, children: ((Widget|Html|string|number)[])|Widget|Html|string|number, [any]:any} | ||
| ---@param args {widget: string, children: any, [any]: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.
imo make a type alias for the original children type and use that
so something like Renderable = Widget|Html|string|number and make children of type Renderable|Renderable[]
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.
nice idea we could use it in some other places too :)
Summary
Idea on improving the the Widget handling when it comes to props, default props, required props and coming from wikicode world where everything in a string.
How did you test this change?