I have an object literal such as the following (all properties are known at compile time):

const foo = { "hello": "hola" };

If foo were an interface rather than a variable, I could easily do something like

/** THEORETICAL ONLY - Does not compile! */ function translate(input: keyof foo): string { return foo[input]; }

However, doing so with a variable does not work, since the compiler cannot find an interface with the name foo .