From 6321c8b52dd37fb3a06d55090a3b2ecc5f2610fb Mon Sep 17 00:00:00 2001 From: lijian19 Date: Wed, 9 Sep 2026 14:17:43 +0800 Subject: [PATCH] fix(ui): correct i18next type augmentation scope and client boundary - src/i18n/types.d.ts had no import/export, so its declare module block was an ambient module declaration shadowing the whole i18next package instead of an augmentation. This resolved allowObjectInHTMLChildren against a broken module, widened HTMLAttributes children to include Record, and broke unrelated components (combobox, dialog, dropdown-menu, sheet, tooltip) plus i18next named imports. Adding a top level import turns it into a proper augmentation. - src/i18n/index.ts barrel now has use client; importing it from a server layout evaluated react-i18next's context-creating module scope in the server graph and failed page data collection with createContext is not a function --- ui/litellm-dashboard/src/i18n/index.ts | 10 ++++++++++ ui/litellm-dashboard/src/i18n/types.d.ts | 23 +++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 ui/litellm-dashboard/src/i18n/index.ts create mode 100644 ui/litellm-dashboard/src/i18n/types.d.ts diff --git a/ui/litellm-dashboard/src/i18n/index.ts b/ui/litellm-dashboard/src/i18n/index.ts new file mode 100644 index 00000000000..b1172a998eb --- /dev/null +++ b/ui/litellm-dashboard/src/i18n/index.ts @@ -0,0 +1,10 @@ +"use client"; + +// ./i18n.ts imports react-i18next, whose module scope calls React context APIs. +// Without this directive, importing the barrel from a server component (e.g. +// app/layout.tsx) evaluates that module in the server graph and the build fails +// with "createContext is not a function". +export { I18nProvider, useI18n } from "./I18nProvider"; +export { getI18n } from "./i18n"; +export type { Locale } from "./resources/registry"; +export { supportedLngs, NAMESPACES } from "./resources/registry"; diff --git a/ui/litellm-dashboard/src/i18n/types.d.ts b/ui/litellm-dashboard/src/i18n/types.d.ts new file mode 100644 index 00000000000..c264e4ee5af --- /dev/null +++ b/ui/litellm-dashboard/src/i18n/types.d.ts @@ -0,0 +1,23 @@ +/** + * Global i18next type augmentation. This file is owned by Agent 4 permanently. + */ +// This import makes this file a module, which turns `declare module` below into +// an augmentation instead of an ambient declaration that would shadow the whole +// i18next package's types. +import "i18next"; + +declare module "i18next" { + interface CustomTypeOptions { + defaultNS: "common"; + // Deliberately NO strict `resources` key augmentation here. i18next v26's + // typed qualified keys are fragile (colons stripped in the union, qualified + // non-default lookups typed `unknown`, resource-shape sensitivity) and, in + // this static-export dashboard, repeatedly broke `next build`'s type check + // for a benefit that is redundant with the guarantees we already have: + // - runtime key correctness is enforced by the readiness gate (ADR-03, + // no raw-key flash) and + // - en/zh key inventory is enforced by A7's check-keys CI gate. + // So keys are typed loosely (`string`), which compiles stably. Common-NS + // keys are still used unprefixed per `defaultNS`. + } +}