Skip to content

Commit d4b2038

Browse files
Copilothotlong
andcommitted
style(i18n): address code review - use optional chaining and stricter types
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com> Agent-Logs-Url: https://github.com/objectstack-ai/objectui/sessions/c9dec823-2a7f-43fa-a55e-6b357fefe3d5
1 parent 814a6b8 commit d4b2038

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

apps/console/src/__tests__/LoadLanguage.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { loadLanguage } from '../loadLanguage';
1313
// Tests
1414
// ---------------------------------------------------------------------------
1515
describe('loadLanguage', () => {
16-
const fetchSpy = vi.fn<(...args: any[]) => Promise<Response>>();
16+
const fetchSpy = vi.fn<(...args: Parameters<typeof fetch>) => Promise<Response>>();
1717

1818
beforeEach(() => {
1919
vi.stubGlobal('fetch', fetchSpy);

apps/console/src/loadLanguage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export async function loadLanguage(lang: string): Promise<Record<string, unknown
1515
}
1616
const json = await res.json();
1717
// Unwrap the spec REST API envelope when present
18-
if (json && typeof json === 'object' && json.data && json.data.translations && typeof json.data.translations === 'object') {
18+
if (json?.data?.translations && typeof json.data.translations === 'object') {
1919
return json.data.translations as Record<string, unknown>;
2020
}
2121
// Fallback: mock server / local dev returns flat translation objects

0 commit comments

Comments
 (0)