From 4f069556eb2b7fe70eb5af8b944cee81c3068e6f Mon Sep 17 00:00:00 2001 From: James Date: Fri, 29 Nov 2019 14:30:13 +0000 Subject: [PATCH] Ensure format arg is typed as key of the bundle messages in the i18n middleware --- src/core/interfaces.d.ts | 2 +- src/core/middleware/i18n.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/interfaces.d.ts b/src/core/interfaces.d.ts index cfb53206d..ded7cac79 100644 --- a/src/core/interfaces.d.ts +++ b/src/core/interfaces.d.ts @@ -680,7 +680,7 @@ export type LocalizedMessages = { * @return * The formatted string. */ - format(key: string, options?: any): string; + format(key: keyof T, options?: any): string; /** * The localized messages if available, or either the default messages or a blank bundle depending on the diff --git a/src/core/middleware/i18n.ts b/src/core/middleware/i18n.ts index 54d0c4316..2fe0f65e2 100644 --- a/src/core/middleware/i18n.ts +++ b/src/core/middleware/i18n.ts @@ -91,7 +91,7 @@ export const i18n = factory(({ properties, middleware: { invalidator, injector, const format = isPlaceholder && !useDefaults ? () => '' - : (key: string, options?: any) => formatMessage(bundle, key, options, locale); + : (key: keyof T, options?: any) => formatMessage(bundle, key as string, options, locale); return Object.create({ format,