app/ui: fix shiki theme string typescript error

This commit is contained in:
Matteo Celani 2026-05-06 15:45:30 +02:00
parent afe16f909a
commit 1be343d4a5
No known key found for this signature in database

View file

@ -2,7 +2,8 @@ import React from "react";
import { Streamdown, defaultRemarkPlugins } from "streamdown";
import remarkCitationParser from "@/utils/remarkCitationParser";
import CopyButton from "./CopyButton";
import type { BundledLanguage, ThemedToken } from "shiki";
import type { BundledLanguage } from "shiki";
import type { ThemeRegistrationAny, ThemedToken } from "@shikijs/types";
import { highlighter, THEME_LIGHT, THEME_DARK } from "@/lib/highlighter";
import { useTheme } from "@/hooks/useTheme";
@ -63,9 +64,10 @@ const CodeBlock = React.memo(
}
try {
const shikiTheme = theme === "dark" ? THEME_DARK : THEME_LIGHT;
const result = highlighter.codeToTokensBase(codeText, {
lang: language as BundledLanguage,
theme: theme === "dark" ? THEME_DARK : THEME_LIGHT,
theme: shikiTheme as ThemeRegistrationAny,
});
tokenCacheRef.current[themeKey] = result;
return result;