{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/17929","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/17929/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/17929/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/17929/events","html_url":"https://github.com/Microsoft/TypeScript/issues/17929","id":251446823,"number":17929,"title":"Index access type from intersection ","user":{"login":"olegdunkan","id":1710435,"avatar_url":"https://avatars0.githubusercontent.com/u/1710435?v=4","gravatar_id":"","url":"https://api.github.com/users/olegdunkan","html_url":"https://github.com/olegdunkan","followers_url":"https://api.github.com/users/olegdunkan/followers","following_url":"https://api.github.com/users/olegdunkan/following{/other_user}","gists_url":"https://api.github.com/users/olegdunkan/gists{/gist_id}","starred_url":"https://api.github.com/users/olegdunkan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olegdunkan/subscriptions","organizations_url":"https://api.github.com/users/olegdunkan/orgs","repos_url":"https://api.github.com/users/olegdunkan/repos","events_url":"https://api.github.com/users/olegdunkan/events{/privacy}","received_events_url":"https://api.github.com/users/olegdunkan/received_events","type":"User","site_admin":false},"labels":[{"id":371615203,"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Working%20as%20Intended","name":"Working as Intended","color":"fbca04","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-08-19T20:02:56Z","updated_at":"2017-08-22T18:28:54Z","closed_at":"2017-08-22T18:19:01Z","body":"**TypeScript Version:**  playground\r\n\r\n**Code**\r\n```ts\r\nvar a: \"x\" | (\"y\" & \"z\");\r\nvar b: {x:number, y:string, z:boolean};\r\nvar c: keyof typeof b;\r\n\r\nc = a; //ok \r\n\r\nvar x:typeof b[typeof a];\r\n```\r\n\r\n**Expected behavior:**\r\n\r\n> An indexed access type T[K] requires K to be a type that is assignable to keyof T\r\n> ...\r\n> T[K] is resolved as follows:\r\n> \r\n> If K is a union type K1 | K2 | ... | Kn, T[K] is equivalent to T[K1] | T[K2] | ... | T[Kn]\r\n> \r\nhttps://github.com/Microsoft/TypeScript/pull/11929\r\n\r\nI expected the type of `x` to be `number`, because  `\"x\" | (\"y\" & \"z\")` is assignable to `keyof  {x:number, y:string, z:boolean}`\r\n\r\n`T[\"x\" | (\"y\" & \"z\")] = T[\"x\"] | T[\"y\" & \"z\"] = number | ? (never or empty)` but result of union is the `number` type; \r\nEdited: \r\n_In other words I expected `T[\"y\" & \"z\"]` to be `never`_\r\n**Actual behavior:**\r\nerror - Type '\"y\" & \"z\"' cannot be used as an index type\r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/324112639","html_url":"https://github.com/Microsoft/TypeScript/issues/17929#issuecomment-324112639","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/17929","id":324112639,"user":{"login":"mhegazy","id":8000722,"avatar_url":"https://avatars3.githubusercontent.com/u/8000722?v=4","gravatar_id":"","url":"https://api.github.com/users/mhegazy","html_url":"https://github.com/mhegazy","followers_url":"https://api.github.com/users/mhegazy/followers","following_url":"https://api.github.com/users/mhegazy/following{/other_user}","gists_url":"https://api.github.com/users/mhegazy/gists{/gist_id}","starred_url":"https://api.github.com/users/mhegazy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhegazy/subscriptions","organizations_url":"https://api.github.com/users/mhegazy/orgs","repos_url":"https://api.github.com/users/mhegazy/repos","events_url":"https://api.github.com/users/mhegazy/events{/privacy}","received_events_url":"https://api.github.com/users/mhegazy/received_events","type":"User","site_admin":false},"created_at":"2017-08-22T18:28:54Z","updated_at":"2017-08-22T18:28:54Z","body":"at run-time an index with an unknown property would result in undefined. if the compiler did not limit the access on only known index types, every generic `T[K]` would be potentially `undefined` and you would have to check for that on every use."}}
{"actor":{"display_login":"mhegazy"}}