-
-
Notifications
You must be signed in to change notification settings - Fork 740
Open
Description
Search terms
loadTranslations, ERR_INVALID_TYPESCRIPT_SYNTAX, infinite recursion, Windows, locales, require, en.cjs
Expected Behavior
loadTranslations("en")
should load the English translation file and fallback gracefully if a locale is missing.- IDE should not flag i18n strings like
i18n.file_0_changed_restarting()
as unresolved.

Actual Behavior
pnpm build
works and doesn't throw errors.- All the i18n values are flagged as unresolved but my IDE (IntelliJ)
- If I run
pnpm test
, I have a recursive loop inloadTranslation
insrc/lib/internationalization/internationalization.ts:69:16
:
/**
* Load TypeDoc's translations for a specified language
*/
export function loadTranslations(lang: string): Record<string, string> {
// Make sure this isn't abused to load some random file by mistake
ok(
/^[A-Za-z-]+$/.test(lang),
"Locale names may only contain letters and dashes",
);
try {
return req(`./locales/${lang}.cjs`);
} catch {
return loadTranslations("en"); // <-- HERE
}
}
Debug
I edited the try/catch to get the error details:
/**
* Load TypeDoc's translations for a specified language
*/
export function loadTranslations(lang: string): Record<string, string> {
// Make sure this isn't abused to load some random file by mistake
ok(
/^[A-Za-z-]+$/.test(lang),
"Locale names may only contain letters and dashes",
);
try {
return req(`./locales/${lang}.cjs`);
} catch (e) {
console.log(e)// SyntaxError [ERR_INVALID_TYPESCRIPT_SYNTAX]
return loadTranslations("en");
}
}
Environment
- Typedoc version: f60f0a4
- TypeScript version: 5.8.3 (from the project typescript version inthe package)
- Node.js version: 23.6.0
- OS: Windows 11 (french)
Metadata
Metadata
Assignees
Labels
No labels