{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/21760","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/21760/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/21760/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/21760/events","html_url":"https://github.com/Microsoft/TypeScript/issues/21760","id":295496249,"number":21760,"title":"Error: Type cannot be used to index type after two indexes","user":{"login":"tenorok","id":1322855,"avatar_url":"https://avatars3.githubusercontent.com/u/1322855?v=4","gravatar_id":"","url":"https://api.github.com/users/tenorok","html_url":"https://github.com/tenorok","followers_url":"https://api.github.com/users/tenorok/followers","following_url":"https://api.github.com/users/tenorok/following{/other_user}","gists_url":"https://api.github.com/users/tenorok/gists{/gist_id}","starred_url":"https://api.github.com/users/tenorok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tenorok/subscriptions","organizations_url":"https://api.github.com/users/tenorok/orgs","repos_url":"https://api.github.com/users/tenorok/repos","events_url":"https://api.github.com/users/tenorok/events{/privacy}","received_events_url":"https://api.github.com/users/tenorok/received_events","type":"User","site_admin":false},"labels":[{"id":113970366,"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Bug","name":"Bug","color":"e11d21","default":false}],"state":"open","locked":false,"assignee":{"login":"sandersn","id":293473,"avatar_url":"https://avatars1.githubusercontent.com/u/293473?v=4","gravatar_id":"","url":"https://api.github.com/users/sandersn","html_url":"https://github.com/sandersn","followers_url":"https://api.github.com/users/sandersn/followers","following_url":"https://api.github.com/users/sandersn/following{/other_user}","gists_url":"https://api.github.com/users/sandersn/gists{/gist_id}","starred_url":"https://api.github.com/users/sandersn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sandersn/subscriptions","organizations_url":"https://api.github.com/users/sandersn/orgs","repos_url":"https://api.github.com/users/sandersn/repos","events_url":"https://api.github.com/users/sandersn/events{/privacy}","received_events_url":"https://api.github.com/users/sandersn/received_events","type":"User","site_admin":false},"assignees":[{"login":"sandersn","id":293473,"avatar_url":"https://avatars1.githubusercontent.com/u/293473?v=4","gravatar_id":"","url":"https://api.github.com/users/sandersn","html_url":"https://github.com/sandersn","followers_url":"https://api.github.com/users/sandersn/followers","following_url":"https://api.github.com/users/sandersn/following{/other_user}","gists_url":"https://api.github.com/users/sandersn/gists{/gist_id}","starred_url":"https://api.github.com/users/sandersn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sandersn/subscriptions","organizations_url":"https://api.github.com/users/sandersn/orgs","repos_url":"https://api.github.com/users/sandersn/repos","events_url":"https://api.github.com/users/sandersn/events{/privacy}","received_events_url":"https://api.github.com/users/sandersn/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/Microsoft/TypeScript/milestones/61","html_url":"https://github.com/Microsoft/TypeScript/milestone/61","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/milestones/61/labels","id":2941810,"number":61,"title":"TypeScript 2.8","description":null,"creator":{"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},"open_issues":223,"closed_issues":45,"state":"open","created_at":"2017-11-28T01:28:09Z","updated_at":"2018-02-08T18:07:13Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2018-02-08T12:36:37Z","updated_at":"2018-02-08T18:12:09Z","closed_at":null,"author_association":"NONE","body":"<!-- If you have a BUG:\r\n  Please fill in the *entire* template below.\r\n-->\r\n\r\n<!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** 2.7.1, 2.8.0-dev.20180208\r\n\r\n<!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:**\r\nType cannot be used to index type\r\n\r\n**Code**\r\n\r\n```ts\r\ninterface IExample {\r\n    foo: {\r\n        bar: {\r\n            baz: number;\r\n        }\r\n    }\r\n}\r\n\r\ntype F = <\r\n    name extends keyof IExample,\r\n    val extends keyof IExample[name]\r\n>() => IExample[name][val]['baz']; // ← Type '\"baz\"' cannot be used to index type 'IExample[name][val]'.\r\n```\r\n\r\n**Expected behavior:**\r\nIn version 2.7.0-dev.20171115 this code was checking without errors.\r\n\r\n**Actual behavior:**\r\nNow in throws error: Type '\"baz\"' cannot be used to index type 'IExample[name][val]'.\r\n\r\n**Playground Link:** <!-- A link to a TypeScript Playground \"Share\" link which demonstrates this behavior -->\r\nhttps://www.typescriptlang.org/play/index.html#src=interface%20IExample%20%7B%0D%0A%20%20%20%20foo%3A%20%7B%0D%0A%20%20%20%20%20%20%20%20bar%3A%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20baz%3A%20number%3B%0D%0A%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%7D%0D%0A%7D%0D%0A%0D%0Atype%20F%20%3D%20%3C%0D%0A%20%20%20%20name%20extends%20keyof%20IExample%2C%0D%0A%20%20%20%20val%20extends%20keyof%20IExample%5Bname%5D%0D%0A%3E()%20%3D%3E%20IExample%5Bname%5D%5Bval%5D%5B'baz'%5D%3B\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/364199927","html_url":"https://github.com/Microsoft/TypeScript/issues/21760#issuecomment-364199927","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/21760","id":364199927,"user":{"login":"sandersn","id":293473,"avatar_url":"https://avatars1.githubusercontent.com/u/293473?v=4","gravatar_id":"","url":"https://api.github.com/users/sandersn","html_url":"https://github.com/sandersn","followers_url":"https://api.github.com/users/sandersn/followers","following_url":"https://api.github.com/users/sandersn/following{/other_user}","gists_url":"https://api.github.com/users/sandersn/gists{/gist_id}","starred_url":"https://api.github.com/users/sandersn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sandersn/subscriptions","organizations_url":"https://api.github.com/users/sandersn/orgs","repos_url":"https://api.github.com/users/sandersn/repos","events_url":"https://api.github.com/users/sandersn/events{/privacy}","received_events_url":"https://api.github.com/users/sandersn/received_events","type":"User","site_admin":false},"created_at":"2018-02-08T18:12:09Z","updated_at":"2018-02-08T18:12:09Z","author_association":"MEMBER","body":"The nut of the problem is that the base constraint of `U extends keyof IExample[T]` is `string`, even though we would like it be `\"bar\"`. This means that `IExample[T][U]` doesn't *have* a constraint, and therefore can't be indexed by anything except `keyof IExample[T][U]`, which \"baz\" is not.\r\n\r\nI think it would be possible to fix this case by changing the rule for keyof types in `computeBaseConstraint` to `return getIndexType(getBaseConstraint(t.target))` instead of just `return stringType`. I'll try it when I have time to see if it works."}}
{"actor":{"display_login":"sandersn"}}