Another way to avoid the error is to use the cast like this:
let secondValue: string = (<any>someObject)[key];
(Note the parenthesis)
The only problem is that this isn't type-safe anymore, as you are casting to any
. But you can always cast back to the correct type.
ps: I'm using typescript 1.7, not sure about previous versions.