mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-29 01:42:19 +00:00
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<string, unknown>, 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
This commit is contained in:
parent
31e3a76d3f
commit
6321c8b52d
2 changed files with 33 additions and 0 deletions
10
ui/litellm-dashboard/src/i18n/index.ts
Normal file
10
ui/litellm-dashboard/src/i18n/index.ts
Normal file
|
|
@ -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";
|
||||
23
ui/litellm-dashboard/src/i18n/types.d.ts
vendored
Normal file
23
ui/litellm-dashboard/src/i18n/types.d.ts
vendored
Normal file
|
|
@ -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`.
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue