From ff1b208a55e02cfcfde042b42f51369ee7b35563 Mon Sep 17 00:00:00 2001 From: "Lucas H. Azevedo" Date: Mon, 5 Oct 2020 01:31:47 -0300 Subject: [PATCH 1/3] Convert icon helper to Typescript --- js/src/common/helpers/{icon.js => icon.tsx} | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) rename js/src/common/helpers/{icon.js => icon.tsx} (53%) diff --git a/js/src/common/helpers/icon.js b/js/src/common/helpers/icon.tsx similarity index 53% rename from js/src/common/helpers/icon.js rename to js/src/common/helpers/icon.tsx index c69a5d6c42..e0dd83521d 100644 --- a/js/src/common/helpers/icon.js +++ b/js/src/common/helpers/icon.tsx @@ -1,11 +1,13 @@ +import { Attributes, Vnode } from 'mithril'; + /** * The `icon` helper displays an icon. * * @param {String} fontClass The full icon class, prefix and the icon’s name. - * @param {Object} attrs Any other attributes to apply. - * @return {Object} + * @param {Attributes} attrs Any other attributes to apply. + * @return {Vnode} */ -export default function icon(fontClass, attrs = {}) { +export default function icon(fontClass: string, attrs: Attributes = {}): Vnode { attrs.className = 'icon ' + fontClass + ' ' + (attrs.className || ''); return ; From f81fbdbf5ccb0c3a49f80341654468eeda3eeb25 Mon Sep 17 00:00:00 2001 From: Lucas Henrique Date: Mon, 5 Oct 2020 17:45:58 -0300 Subject: [PATCH 2/3] Use namespaced Mithril import for consistency Use "import * as Mithril" instead of "import { ... } from" --- js/src/common/helpers/icon.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/src/common/helpers/icon.tsx b/js/src/common/helpers/icon.tsx index e0dd83521d..bd3da8735f 100644 --- a/js/src/common/helpers/icon.tsx +++ b/js/src/common/helpers/icon.tsx @@ -1,13 +1,13 @@ -import { Attributes, Vnode } from 'mithril'; +import * as Mithril from 'mithril'; /** * The `icon` helper displays an icon. * * @param {String} fontClass The full icon class, prefix and the icon’s name. - * @param {Attributes} attrs Any other attributes to apply. - * @return {Vnode} + * @param {Mithril.Attributes} attrs Any other attributes to apply. + * @return {Mithril.Vnode} */ -export default function icon(fontClass: string, attrs: Attributes = {}): Vnode { +export default function icon(fontClass: string, attrs: Mithril.Attributes = {}): Mithril.Vnode { attrs.className = 'icon ' + fontClass + ' ' + (attrs.className || ''); return ; From c53d42c0173117a227b8c93e35612846573eebfa Mon Sep 17 00:00:00 2001 From: Lucas Henrique Date: Mon, 5 Oct 2020 18:38:26 -0300 Subject: [PATCH 3/3] Remove unnecessary JSDoc types from icon helper They can be inferred from Typescript types --- js/src/common/helpers/icon.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/js/src/common/helpers/icon.tsx b/js/src/common/helpers/icon.tsx index bd3da8735f..cb01a13474 100644 --- a/js/src/common/helpers/icon.tsx +++ b/js/src/common/helpers/icon.tsx @@ -3,9 +3,8 @@ import * as Mithril from 'mithril'; /** * The `icon` helper displays an icon. * - * @param {String} fontClass The full icon class, prefix and the icon’s name. - * @param {Mithril.Attributes} attrs Any other attributes to apply. - * @return {Mithril.Vnode} + * @param fontClass The full icon class, prefix and the icon’s name. + * @param attrs Any other attributes to apply. */ export default function icon(fontClass: string, attrs: Mithril.Attributes = {}): Mithril.Vnode { attrs.className = 'icon ' + fontClass + ' ' + (attrs.className || '');