From 6a542c870d56704c4849b4e208611c8ac2c5cdd7 Mon Sep 17 00:00:00 2001 From: Ophelia Goldstein <159258143+opheliagoldstein@users.noreply.github.com> Date: Sat, 11 Oct 2025 21:30:08 +0300 Subject: [PATCH] fix: resolve vscode errors inside colors related code (#4556) Co-authored-by: Alexandr --- src/common/utils.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/common/utils.js b/src/common/utils.js index c9ceb24a..f451d8b9 100644 --- a/src/common/utils.js +++ b/src/common/utils.js @@ -227,8 +227,8 @@ const request = (data, headers) => { * @param {string=} args.bg_color Card background color. * @param {string=} args.border_color Card border color. * @param {string=} args.ring_color Card ring color. - * @param {string=} args.theme Card theme. - * @param {string=} args.fallbackTheme Fallback theme. + * @param {keyof themes=} args.theme Card theme. + * @param {keyof themes=} args.fallbackTheme Fallback theme. * @returns {CardColors} Card colors. */ const getCardColors = ({ @@ -242,9 +242,13 @@ const getCardColors = ({ fallbackTheme = "default", }) => { const defaultTheme = themes[fallbackTheme]; - const selectedTheme = themes[theme] || defaultTheme; + const isThemeProvided = theme !== null && theme !== undefined; + const selectedTheme = isThemeProvided ? themes[theme] : defaultTheme; const defaultBorderColor = - selectedTheme.border_color || defaultTheme.border_color; + "border_color" in selectedTheme + ? selectedTheme.border_color + : // @ts-ignore + defaultTheme.border_color; // get the color provided by the user else the theme color // finally if both colors are invalid fallback to default theme @@ -256,6 +260,7 @@ const getCardColors = ({ // get the color provided by the user else the theme color // finally if both colors are invalid we use the titleColor const ringColor = fallbackColor( + // @ts-ignore ring_color || selectedTheme.ring_color, titleColor, ); @@ -327,7 +332,7 @@ const UPSTREAM_API_ERRORS = [ * @param {string=} args.renderOptions.text_color Card text color. * @param {string=} args.renderOptions.bg_color Card background color. * @param {string=} args.renderOptions.border_color Card border color. - * @param {string=} args.renderOptions.theme Card theme. + * @param {keyof themes=} args.renderOptions.theme Card theme. * @param {boolean=} args.renderOptions.show_repo_link Whether to show repo link or not. * @returns {string} The SVG markup. */