{"action":"opened","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/12758","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/12758/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/12758/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/12758/events","html_url":"https://github.com/Microsoft/TypeScript/issues/12758","id":194313226,"number":12758,"title":"Should T[K] be narrowed when K is narrowed?","user":{"login":"Strate","id":392644,"avatar_url":"https://avatars.githubusercontent.com/u/392644?v=3","gravatar_id":"","url":"https://api.github.com/users/Strate","html_url":"https://github.com/Strate","followers_url":"https://api.github.com/users/Strate/followers","following_url":"https://api.github.com/users/Strate/following{/other_user}","gists_url":"https://api.github.com/users/Strate/gists{/gist_id}","starred_url":"https://api.github.com/users/Strate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Strate/subscriptions","organizations_url":"https://api.github.com/users/Strate/orgs","repos_url":"https://api.github.com/users/Strate/repos","events_url":"https://api.github.com/users/Strate/events{/privacy}","received_events_url":"https://api.github.com/users/Strate/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-08T11:34:02Z","updated_at":"2016-12-08T11:34:02Z","closed_at":null,"body":"**TypeScript Version:**  2.1.4\r\n\r\n**Code**\r\n\r\n```ts\r\ninterface Entity {\r\n    a: string;\r\n    b: number;\r\n}\r\n\r\nconst entity: Entity = {a: \"\", b: 0};\r\nfunction setFieldValue<K extends keyof Entity>(f: K, v: Entity[K]) { \r\n    if (f === \"a\") {\r\n        entity.a = v;\r\n    } else if (f === \"b\") {\r\n        entity.b = v;\r\n    }\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\nNo compilation error\r\n**Actual behavior:**\r\n\"Type 'Entity[K]' is not assignable to type 'string'\"\r\n\"Type 'Entity[K]' is not assignable to type 'number'\"\r\n"}}
{"actor":{"display_login":"Strate"}}