From 46a8339ea7b2cc3b50ce9c29da4fcaf78f3669e1 Mon Sep 17 00:00:00 2001 From: HIRANO Satoshi Date: Fri, 24 Feb 2023 14:45:20 +0900 Subject: [PATCH 1/2] I18N.tr has wrong options overload type fix aurelia#352. Without this we get errors with i18n.tr("key", {param: value}). --- src/i18n.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i18n.ts b/src/i18n.ts index 0dac2902..4d09964d 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -122,7 +122,7 @@ export class I18N { } // tslint:disable-next-line: max-line-length - public tr | undefined = string>(key: string | string[], options?: TOptions) { + public tr | undefined = string>(key: string | string[], options?: TOptions) { let fullOptions = this.globalVars; if (options !== undefined) { From 537c8d1643587a6055d8124d20db140e5260dcce Mon Sep 17 00:00:00 2001 From: Vildan Softic Date: Mon, 6 Mar 2023 19:18:24 +0100 Subject: [PATCH 2/2] chore: add test; bump version and build dts --- dist/aurelia-i18n.d.ts | 2 +- package.json | 2 +- test/unit/i18n.spec.ts | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/dist/aurelia-i18n.d.ts b/dist/aurelia-i18n.d.ts index a99b4792..aa18d459 100644 --- a/dist/aurelia-i18n.d.ts +++ b/dist/aurelia-i18n.d.ts @@ -35,7 +35,7 @@ export declare class I18N { nf(options?: Intl.NumberFormatOptions, locales?: string | string[]): Intl.NumberFormat; uf(numberLike: string, locale?: string): number; df(options?: Intl.DateTimeFormatOptions, locales?: string | string[]): Intl.DateTimeFormat; - tr | undefined = string>(key: string | string[], options?: TOptions): TResult; + tr | undefined = string>(key: string | string[], options?: TOptions): TResult; registerGlobalVariable(key: string, value: any): void; unregisterGlobalVariable(key: string): void; /** diff --git a/package.json b/package.json index e401a2a1..1f6d03c0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aurelia-i18n", - "version": "4.0.3", + "version": "4.0.4", "description": "A plugin that provides i18n support.", "keywords": [ "aurelia", diff --git a/test/unit/i18n.spec.ts b/test/unit/i18n.spec.ts index 26dbc2bb..fa71eaef 100644 --- a/test/unit/i18n.spec.ts +++ b/test/unit/i18n.spec.ts @@ -84,6 +84,11 @@ describe("testing i18n translations", () => { expect(sut.i18next.options.fallbackLng).toEqual(["en"]); }); + it("should have proper overload types for tr", () => { + const value = 1; + sut.tr("key", {score: value}); + }); + it("should map complex object", () => { const options = { threshold: {