Skip to content

Commit

Permalink
Ensure format arg is typed as key of the bundle messages in the i18n …
Browse files Browse the repository at this point in the history
…middleware
  • Loading branch information
JamesLMilner committed Nov 29, 2019
1 parent 0a7bfeb commit 4f06955
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core/interfaces.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ export type LocalizedMessages<T extends Messages> = {
* @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
Expand Down
2 changes: 1 addition & 1 deletion src/core/middleware/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4f06955

Please sign in to comment.