typesafe-i18n
typesafe-i18n copied to clipboard
Argument with custom type is not passed to the formatter function
Version
5.26.2
Describe the bug
Following this instruction failed to pass an argument of custom type to the formatter function.
Reproduction
// en/index.ts
dateRange: "{0: DateRange|formatDateRange}",
// custom-types.ts
export interface DateRange {
from: Date;
to: Date;
}
// formatters.ts
formatDateRange: (value) => {
console.log(value) // correctly typed but undefined
// using date-fns
return `${format(value.from, "MM/dd/yyyy", {
locale: localeDate[locale],
})} - ${format(value.to, "MM/dd/yyyy", {
locale: localeDate[locale],
})}`;
},
// app.js
LL.dateRange({ from: new Date(), to: new Date() })
Logs
Cannot read property 'from' of undefined
Value correctly typed but the value undefined
Config
{
"baseLocale": "en",
"adapter": "react",
"$schema": "https://unpkg.com/[email protected]/schema/typesafe-i18n.json"
}
Additional information
No response