ttag-org / ttag

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

jt documentation and type is incorrect #233

Closed tlrobinson closed 7 months ago

tlrobinson commented 2 years ago

This documentation

The biggest difference between jt and t is that t concatenates translations and expressions all together into a single string, while jt returns an array of the translated strings and expressions that can be used in jsx.

and this TypeScript type

https://github.com/ttag-org/ttag/blob/master/types/index.d.ts#L22

aren't quite right. jt returns an array of strings and any template variables.

I think this is a better type:

export function jt<T>(strings: TemplateStringsArray, ...expr: T[]): string | (string | T)[];

A workaround is to redeclare the type in some TypesScript file in your project:

import "ttag";

declare module "ttag" {
  function jt<T>(strings: TemplateStringsArray, ...expr: T[]): string | (string | T)[];
}
AlexMost commented 2 years ago

good point, this needs to be fixed

AlexMost commented 7 months ago

done in 1.8.6 :heavy_check_mark: