From b50d806534bbeb6862412b89f6ff8e334572e80b 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) --- js/src/common/helpers/{highlight.js => highlight.tsx} | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) rename js/src/common/helpers/{highlight.js => highlight.tsx} (76%) diff --git a/js/src/common/helpers/highlight.js b/js/src/common/helpers/highlight.tsx similarity index 76% rename from js/src/common/helpers/highlight.js rename to js/src/common/helpers/highlight.tsx index 0674bed0b0..42236a32df 100644 --- a/js/src/common/helpers/highlight.js +++ b/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