From 33f0c9153e3c2c6af3fad602ba4ae5bd307d36b7 Mon Sep 17 00:00:00 2001 From: Ophelia Goldstein <159258143+opheliagoldstein@users.noreply.github.com> Date: Sat, 11 Oct 2025 22:40:33 +0300 Subject: [PATCH] fix: resolve vscode errors inside cards svg generation code (#4558) Co-authored-by: Alexandr --- src/cards/gist.js | 1 + src/cards/repo.js | 1 + src/cards/stats.js | 27 ++++++++++++++++----------- src/cards/top-languages.js | 3 +++ src/cards/wakatime.js | 2 ++ src/common/color.js | 4 ++-- 6 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/cards/gist.js b/src/cards/gist.js index 9b6c128d..ecace838 100644 --- a/src/cards/gist.js +++ b/src/cards/gist.js @@ -96,6 +96,7 @@ const renderGistCard = (gistData, options = {}) => { ); const languageName = language || "Unspecified"; + // @ts-ignore const languageColor = languageColors[languageName] || "#858585"; const svgLanguage = createLanguageNode(languageName, languageColor); diff --git a/src/cards/repo.js b/src/cards/repo.js index 81d32066..9f28c7a5 100644 --- a/src/cards/repo.js +++ b/src/cards/repo.js @@ -1,4 +1,5 @@ // @ts-check + import { Card } from "../common/Card.js"; import { getCardColors } from "../common/color.js"; import { I18n } from "../common/I18n.js"; diff --git a/src/cards/stats.js b/src/cards/stats.js index 301a6d78..a0b12096 100644 --- a/src/cards/stats.js +++ b/src/cards/stats.js @@ -392,21 +392,24 @@ const renderStatsCard = (stats, options = {}) => { // filter out hidden stats defined by user & create the text nodes const statItems = Object.keys(STATS) .filter((key) => !hide.includes(key)) - .map((key, index) => + .map((key, index) => { + // @ts-ignore + const stats = STATS[key]; + // create the text nodes, and pass index so that we can calculate the line spacing - createTextNode({ - icon: STATS[key].icon, - label: STATS[key].label, - value: STATS[key].value, - id: STATS[key].id, - unitSymbol: STATS[key].unitSymbol, + return createTextNode({ + icon: stats.icon, + label: stats.label, + value: stats.value, + id: stats.id, + unitSymbol: stats.unitSymbol, index, showIcons: show_icons, shiftValuePos: 79.01 + (isLongLocale ? 50 : 0), bold: text_bold, number_format, - }), - ); + }); + }); if (statItems.length === 0 && hide_rank) { throw new CustomError( @@ -541,14 +544,16 @@ const renderStatsCard = (stats, options = {}) => { const labels = Object.keys(STATS) .filter((key) => !hide.includes(key)) .map((key) => { + // @ts-ignore + const stats = STATS[key]; if (key === "commits") { return `${i18n.t("statcard.commits")} ${getTotalCommitsYearLabel( include_all_commits, commits_year, i18n, - )} : ${STATS[key].value}`; + )} : ${stats.value}`; } - return `${STATS[key].label}: ${STATS[key].value}`; + return `${stats.label}: ${stats.value}`; }) .join(", "); diff --git a/src/cards/top-languages.js b/src/cards/top-languages.js index 569ccaae..76c02fad 100644 --- a/src/cards/top-languages.js +++ b/src/cards/top-languages.js @@ -1,4 +1,5 @@ // @ts-check + import { Card } from "../common/Card.js"; import { getCardColors } from "../common/color.js"; import { createProgressNode } from "../common/createProgressNode.js"; @@ -180,6 +181,7 @@ const trimTopLanguages = (topLangs, langs_count, hide) => { // while filtering out if (hide) { hide.forEach((langName) => { + // @ts-ignore langsToHide[lowercaseTrim(langName)] = true; }); } @@ -188,6 +190,7 @@ const trimTopLanguages = (topLangs, langs_count, hide) => { langs = langs .sort((a, b) => b.size - a.size) .filter((lang) => { + // @ts-ignore return !langsToHide[lowercaseTrim(lang.name)]; }) .slice(0, langsCount); diff --git a/src/cards/wakatime.js b/src/cards/wakatime.js index b2fec340..5dadcdab 100644 --- a/src/cards/wakatime.js +++ b/src/cards/wakatime.js @@ -65,6 +65,7 @@ const formatLanguageValue = ({ display_format, lang }) => { * @returns {string} The compact layout language SVG node. */ const createCompactLangNode = ({ lang, x, y, display_format }) => { + // @ts-ignore const color = languageColors[lang.name] || "#858585"; const value = formatLanguageValue({ display_format, lang }); @@ -325,6 +326,7 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => { // const progress = (width * lang.percent) / 100; const progress = ((width - 25) * language.percent) / 100; + // @ts-ignore const languageColor = languageColors[language.name] || "#858585"; const output = ` diff --git a/src/common/color.js b/src/common/color.js index 8047ad06..759a07ca 100644 --- a/src/common/color.js +++ b/src/common/color.js @@ -68,8 +68,8 @@ const fallbackColor = (color, fallbackColor) => { * @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 {keyof themes=} args.theme Card theme. - * @param {keyof themes=} args.fallbackTheme Fallback theme. + * @param {string=} args.theme Card theme. + * @param {string=} args.fallbackTheme Fallback theme. * @returns {CardColors} Card colors. */ const getCardColors = ({