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

Convert icon helper to Typescript #2360

Merged
merged 3 commits into from
Oct 5, 2020

Conversation

lhsazevedo
Copy link
Contributor

@lhsazevedo lhsazevedo commented Oct 5, 2020

Convert common icon helper to Typescript. See #3533

Confirmed

  • Frontend changes: tested on a local Flarum installation.

Copy link
Member

@dsevillamartin dsevillamartin left a 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.

@lhsazevedo
Copy link
Contributor Author

Thank you! Let me know if I should update the imports, no problem.

*/
export default function icon(fontClass, attrs = {}) {
export default function icon(fontClass: string, attrs: Attributes = {}): Vnode {
Copy link
Member

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?

Copy link
Member

@dsevillamartin dsevillamartin Oct 5, 2020

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.

@@ -1,11 +1,13 @@
import { Attributes, Vnode } from 'mithril';
Copy link
Member

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.

Copy link
Contributor Author

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
@askvortsov1 askvortsov1 merged commit 8c46b37 into flarum:master Oct 5, 2020
@lhsazevedo lhsazevedo deleted the icon-typescript branch October 5, 2020 22:45
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.

4 participants