ttag-org / ttag

:orange_book: simple approach for javascript localization
https://ttag.js.org/
MIT License
344 stars 43 forks source link

msgid no longer supports string types #275

Closed jorrit closed 9 months ago

jorrit commented 9 months ago

I use msgid inside ngettext to get a plural string. I also add some other, nonnumeric arguments:

        {ngettext(
          msgid`Based on ${numberOfRatings} review of customers that traveled with ${supplierName}.`,
          `Based on ${numberOfRatings} reviews of customers that traveled with ${supplierName}.`,
          numberOfRatings
        )}

This used to work fine. However, in 1.8.0 typescript was introduced, and the type of msgid is:

export declare function msgid(strings: TemplateStringsArray, ...exprs: number[]): StringWithRawData;

The resulting error is:

TS2345: Argument of type string is not assignable to parameter of type number

I think the type of ...exprs should be any[], just like with the t function.

Related to #267.

stoyanovk commented 9 months ago

It's my wrong, I noticed it, and fixed in https://github.com/ttag-org/ttag/pull/273/files#diff-a2a171449d862fe29692ce031981047d7ab755ae7f84c707aef80701b3ea0c80R42

We will update the lib near time

jorrit commented 9 months ago

Thanks!

AlexMost commented 9 months ago

You can try fix in ttag@1.8.5. Thanks for the report and big thank to @stoyanovk for the fix :muscle: