Open davidlewisbates1980 opened 1 month ago
I am not sure this will help, but I choose one language as a primary and export the type of the translations from it. Then I use this Type to check all other translations are the same using satisfies
and also I can import it elsewhere in my codebase and get the types from it. Here is a code snippet of how I used this type to infer the correct type.
export const questions = [
'How are you?',
'What is your height?',
'What is your name?',
] satisfies (keyof Messages['exampleQuestions']['questions'])[];
Here Messages is the type of the object defined in my translation file.
Firstly, I'm absolutely loving this library. Everything was very intuitive. However, I'm trying to build a menu in React from an array of objects and the strong typing of
next-international
is causing a problem. It doesn't like me passing non-literal string intot(...)
:It first of all says
Expected 2 arguments, but got 1
, but when I add an empty object as a second parameter, it says it can't find an overloaded version with that signature.Is there a way around this? The best I've found is to enumerate the possible string array values:
Anything neater you can suggest?