ITADN

Nesting of translations

#29Closeddartess 创建于 2023-05-17
D
dartesscommented
``` const messages = i18n('post', { a: { b: { c: 'deep value', }, }, }); ``` Is this a valid construct or not? If not, it should be described in the documentation. If valid, we should fix the work of the functions and fix the types: Now it works, but TS is throwing an error: ``` Type '{ b: { c: string; }; }' is not assignable to type 'Translation'. Object literal may only specify known properties, and 'b' does not exist in type 'TranslationFunction<any[], string | TranslationsJSON | TranslationFunction<any[], string | TranslationsJSON | TranslationFunction<any[], string | TranslationsJSON | TranslationFunction<any[], string | ... 1 more ... | TranslationFunction<...>>>>>'.(2322) ``` Also it doesn't work with functions: ``` const messages = i18n('post', { a: { b: { c: count({ one: '{count} comment', many: '{count} comments', }) }, }, }); ``` ``` Uncaught TypeError: t.a.b.c is not a function ```
关闭于 2023-11-26 3 条评论