Closed blarsern closed 1 year ago
Ouch, yep that was a mistake I forgot about the returnObject parameter. So it really should be unknown
or any
right?
Probably not used a lot ;)
Not sure what's best of unknown or any..
ok so the proper result seems to be TResult
which can be string | object | Array<string | object> | undefined
.
Please give the fixed version in the PR a try. Clone the tr-result branch, run npm run build
and then install in your project via npm install ../path/to/your/local/clone/root
.
If all is good we can merge and create another patch release.
Well tested it.
Now this simple code fails: return { name: this.i18n.tr('enums.myEnum.ngh') };
TS2322: Type 'TrResult' is not assignable to type 'string'. Type 'object' is not assignable to type 'string'.
To fix this, i have to add toString: return { name: this.i18n.tr('enums.myEnum.ngh').toString() };
var a:string = this.i18n.tr('enums.myEnum.ngh'); //Not working var a:string = this.i18n.tr('enums.myEnum.ngh').toString(); //Working
So basically this will require a lot of toString() everywhere.
Too much work to get it to compile, so didn't test arrays :)
Thx for the Test and the Testcase, I'll fix that when at the PC.
ok lets give the next version a try, I've pushed the changes @blarsern
Seems to be working perfectly @zewa666
Thanks!
I'm submitting a bug report
Please tell us about your environment:
Operating System: Windows 10
Node Version: 14.15.4
NPM Version: 6.14.11
JSPM OR Webpack AND Version Webpack 4.4.1
Browser: Chrome
Language: Typescript 3.2.2
Current behavior:
dist/aurelia-i18n.d.ts changed 27th of mars 2019:
Changed from: tr(key: string | string[], options?: i18next.TranslationOptions
To: tr(key: string | string[], options?: i18next.TOptions
But in 18n.ts it's still any: public tr(key: string | string[], options?: i18next.TOptions
return this.i18next.t(key, fullOptions); }
So after upgrade from beta 5 this doesn't compile anymore: let dayNames: Array = this.i18n.tr('weekdays', { returnObjects: true });
Expected/desired behavior: Returning arrays should work ?