From b55aaa4cff7146aee65264ed49ff864921ad22e1 Mon Sep 17 00:00:00 2001 From: Alexandr Garbuzov Date: Mon, 11 Sep 2023 11:47:55 +0300 Subject: [PATCH] refactor: fix card colors type and function to resolve vscode type errors (#3191) --- src/common/utils.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/common/utils.js b/src/common/utils.js index 4b5dced..ac3ecc8 100644 --- a/src/common/utils.js +++ b/src/common/utils.js @@ -198,12 +198,12 @@ const flexLayout = ({ items, gap, direction, sizes = [] }) => { /** * Object containing card colors. * @typedef {{ - * titleColor: string | string[]; - * iconColor: string | string[]; - * textColor: string | string[]; + * titleColor: string; + * iconColor: string; + * textColor: string; * bgColor: string | string[]; - * borderColor: string | string[]; - * ringColor: string | string[]; + * borderColor: string; + * ringColor: string; * }} CardColors */ @@ -267,6 +267,18 @@ const getCardColors = ({ "#" + defaultBorderColor, ); + if ( + typeof titleColor !== "string" || + typeof textColor !== "string" || + typeof ringColor !== "string" || + typeof iconColor !== "string" || + typeof borderColor !== "string" + ) { + throw new Error( + "Unexpected behavior, all colors except background should be string.", + ); + } + return { titleColor, iconColor, textColor, bgColor, borderColor, ringColor }; };