for..in variable does not have the type keyof T · Issue #12314 · microsoft/TypeScript (original) (raw)

function set<T, K extends keyof T>(obj: T, key: K, value: T[K]) { obj[key] = value; }

var O = { a: "string" };

// var k: keyof typeof O; for (var k in O) { set(O, k, "another"); // string is not assignable to "a" }