Closed Fxlr8 closed 2 years ago
Also the count
function type says that it returns a function:
But if you try to call it, you get this
Uncaught TypeError: formatBanana is not a function
It happens because of the error in TypeScript Intl.NumberFormat.format
types.
We do not create our own types, but re-use TS types for Intl
module https://github.com/nanostores/i18n/blob/main/formatter/index.d.ts#L6-L7
Seems like we need to migrate to custom types.
Can you create a separate issue for count
?
Fixed 2a9cae3
Also the count function type says that it returns a function
count
should be used only inside i18n({ … })
call.
TypeScript dynamic types can be tricky. I didn’t found a way to solve type problem of converting types inside i18n
to t
types. Think about it as trade off for types maintainability.
https://github.com/nanostores/i18n/blob/main/create-i18n/index.d.ts#L36-L44
Released in 0.2.1.
The documentation clearly says that they accept a second argument: https://github.com/nanostores/i18n/blob/99d21a5b709db9a1127b2ac529b3765f9be1dce6/README.md?plain=1#L209-L226
But your typings do not agree with that: