Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ export interface StoresApi {
}

// @public
export type Translations = Record<string, {
export type Translations = Record<TranslationKey, {
[ietfLanguageTag: string]: string;
}>;

Expand Down
15 changes: 14 additions & 1 deletion packages/element-web-module-api/src/api/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,25 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/

declare global {
// Declare this in the global scope so that it can be overridden with the
// project's translation keys when used. Ideally, this 'never' declaration
// would be the default such that any calls would be a type error unless
// the project provided an override. Unfortunately, vite-plugin-dts doesn't
// output this declaration into the .d.ts file so TranslationKey is just left
// as an undefined type which somehow Typescript considers to be totally fine.
// https://github.com/qmhc/unplugin-dts/issues/419 is a bug about these declarations
// not being output as of version 4.5.1, but at time of writing we use 4.5.0 and
// it still doesn't appear.
type TranslationKey = never;
}

/**
* The translations for the module.
* @public
*/
export type Translations = Record<
string,
TranslationKey,
{
[ietfLanguageTag: string]: string;
}
Expand Down
Loading