-
-
Notifications
You must be signed in to change notification settings - Fork 835
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 icon helper to Typescript #2360
Conversation
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 is good. I've edited your PR description so that merging this doesn't close the issue.
Not sure if we want to enforce things like Mithril.Attributes
and Mithril.Vnode
instead of importing individually - I'm fine with either.
Thank you! Let me know if I should update the imports, no problem. |
js/src/common/helpers/icon.tsx
Outdated
*/ | ||
export default function icon(fontClass, attrs = {}) { | ||
export default function icon(fontClass: string, attrs: Attributes = {}): Vnode { |
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 we want to use ComponentAttrs
instead of Mithril's Attributes
, or do we only want to do that for our custom components?
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 is not necessarily a component, and it doesn't really matter as ComponentAttrs are mainly used for the this.attrs
type hinting in component classes. It doesn't apply here.
js/src/common/helpers/icon.tsx
Outdated
@@ -1,11 +1,13 @@ | |||
import { Attributes, Vnode } from 'mithril'; |
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.
Tbh, I would prefer sticking to Mithril.Vnode
and Mithril.Attributes
just for sake of consistency.
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.
Done
Use "import * as Mithril" instead of "import { ... } from"
They can be inferred from Typescript types
Convert common icon helper to Typescript. See #3533
Confirmed