From 912a0381c30c40e56bf3b744ce084c1fe2bcb942 Mon Sep 17 00:00:00 2001 From: daniellesniak Date: Sat, 23 Jan 2021 22:43:40 +0100 Subject: [PATCH] Convert highlight helper to Typescript (#2532) --- .../src/common/helpers/{highlight.js => highlight.tsx} | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) rename framework/core/js/src/common/helpers/{highlight.js => highlight.tsx} (76%) diff --git a/framework/core/js/src/common/helpers/highlight.js b/framework/core/js/src/common/helpers/highlight.tsx similarity index 76% rename from framework/core/js/src/common/helpers/highlight.js rename to framework/core/js/src/common/helpers/highlight.tsx index 0674bed0b..42236a32d 100644 --- a/framework/core/js/src/common/helpers/highlight.js +++ b/framework/core/js/src/common/helpers/highlight.tsx @@ -1,16 +1,16 @@ +import * as Mithril from 'mithril'; import { truncate } from '../utils/string'; /** * The `highlight` helper searches for a word phrase in a string, and wraps * matches with the tag. * - * @param {String} string The string to highlight. - * @param {String|RegExp} phrase The word or words to highlight. - * @param {Integer} [length] The number of characters to truncate the string to. + * @param string The string to highlight. + * @param phrase The word or words to highlight. + * @param [length] The number of characters to truncate the string to. * The string will be truncated surrounding the first match. - * @return {Object} */ -export default function highlight(string, phrase, length) { +export default function highlight(string: string, phrase: string | RegExp, length?: number): Mithril.Vnode | string { if (!phrase && !length) return string; // Convert the word phrase into a global regular expression (if it isn't