From 8f282d54d2830e268d80ae27a12b49da60d64553 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 13 Jan 2025 14:13:20 +0100 Subject: [PATCH] Type duplicates --- .../builder/src/helpers/{duplicate.js => duplicate.ts} | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) rename packages/builder/src/helpers/{duplicate.js => duplicate.ts} (92%) diff --git a/packages/builder/src/helpers/duplicate.js b/packages/builder/src/helpers/duplicate.ts similarity index 92% rename from packages/builder/src/helpers/duplicate.js rename to packages/builder/src/helpers/duplicate.ts index 361e1faa25..4816bcfd7b 100644 --- a/packages/builder/src/helpers/duplicate.js +++ b/packages/builder/src/helpers/duplicate.ts @@ -10,13 +10,13 @@ * * Repl */ -export const duplicateName = (name, allNames) => { +export const duplicateName = (name: string, allNames: string[]) => { const duplicatePattern = new RegExp(`\\s(\\d+)$`) const baseName = name.split(duplicatePattern)[0] const isDuplicate = new RegExp(`${baseName}\\s(\\d+)$`) // get the sequence from matched names - const sequence = [] + const sequence: number[] = [] allNames.filter(n => { if (n === baseName) { return true @@ -71,9 +71,9 @@ export const duplicateName = (name, allNames) => { * flat array of strings */ export const getSequentialName = ( - items, - prefix, - { getName = x => x, numberFirstItem = false } = {} + items: string[], + prefix: string, + { getName = (x: string) => x, numberFirstItem = false } = {} ) => { if (!prefix?.length || !getName) { return null