Having an object like
const translations = {
say_hello: 'hello {{name}}',
};
I'd like to extract the exact type of the object, like
type Translations = {
say_hello: 'hello {{name}}',
}
So far I'm playing around something like
type GetExactType<T> = {[K in keyof T]-?: T[K]};
but it doesn't work as expected, because
GetExactType<typeof translations>;
resolves to
{
say_hello: string,
}
Any ideas?
translations; the information you want has already been discarded. You can change the type of the initializer via aconstassertion like this but I don't know if that meets your needs.GetExactType<typeof translations>to returnTranslations?