interface IStringDictionary { [name: string]: V; } interface INumberDictionary { [idx: number]: V; } declare function forEach(from: IStringDictionary | INumberDictionary, callback: (entry: { key: any; value: T; }, remove: () => void) => any); let count = 0; forEach({ toString: 123 }, () => count++);