{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/10941","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/10941/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/10941/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/10941/events","html_url":"https://github.com/Microsoft/TypeScript/issues/10941","id":177236884,"number":10941,"title":"Omit index signature with generic type constraints?","user":{"login":"JabX","id":3266897,"avatar_url":"https://avatars.githubusercontent.com/u/3266897?v=3","gravatar_id":"","url":"https://api.github.com/users/JabX","html_url":"https://github.com/JabX","followers_url":"https://api.github.com/users/JabX/followers","following_url":"https://api.github.com/users/JabX/following{/other_user}","gists_url":"https://api.github.com/users/JabX/gists{/gist_id}","starred_url":"https://api.github.com/users/JabX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JabX/subscriptions","organizations_url":"https://api.github.com/users/JabX/orgs","repos_url":"https://api.github.com/users/JabX/repos","events_url":"https://api.github.com/users/JabX/events{/privacy}","received_events_url":"https://api.github.com/users/JabX/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"RyanCavanaugh","id":6685088,"avatar_url":"https://avatars.githubusercontent.com/u/6685088?v=3","gravatar_id":"","url":"https://api.github.com/users/RyanCavanaugh","html_url":"https://github.com/RyanCavanaugh","followers_url":"https://api.github.com/users/RyanCavanaugh/followers","following_url":"https://api.github.com/users/RyanCavanaugh/following{/other_user}","gists_url":"https://api.github.com/users/RyanCavanaugh/gists{/gist_id}","starred_url":"https://api.github.com/users/RyanCavanaugh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RyanCavanaugh/subscriptions","organizations_url":"https://api.github.com/users/RyanCavanaugh/orgs","repos_url":"https://api.github.com/users/RyanCavanaugh/repos","events_url":"https://api.github.com/users/RyanCavanaugh/events{/privacy}","received_events_url":"https://api.github.com/users/RyanCavanaugh/received_events","type":"User","site_admin":false},"assignees":[{"login":"RyanCavanaugh","id":6685088,"avatar_url":"https://avatars.githubusercontent.com/u/6685088?v=3","gravatar_id":"","url":"https://api.github.com/users/RyanCavanaugh","html_url":"https://github.com/RyanCavanaugh","followers_url":"https://api.github.com/users/RyanCavanaugh/followers","following_url":"https://api.github.com/users/RyanCavanaugh/following{/other_user}","gists_url":"https://api.github.com/users/RyanCavanaugh/gists{/gist_id}","starred_url":"https://api.github.com/users/RyanCavanaugh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RyanCavanaugh/subscriptions","organizations_url":"https://api.github.com/users/RyanCavanaugh/orgs","repos_url":"https://api.github.com/users/RyanCavanaugh/repos","events_url":"https://api.github.com/users/RyanCavanaugh/events{/privacy}","received_events_url":"https://api.github.com/users/RyanCavanaugh/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2016-09-15T17:27:44Z","updated_at":"2016-09-16T19:43:30Z","closed_at":null,"body":"**TypeScript Version:** nightly 2.1-20160914\r\n\r\nI have a base class that takes a generic parameter with a constraint that is an index signature. Something like\r\n```ts\r\ninterface Constraint {\r\n    [key: string]: number\r\n}\r\n\r\nclass Base<T extends Constraint> {\r\n    entity: T\r\n}\r\n```\r\n\r\nThis class is meant to be inherited from and provided with another type that satisfies the index signature but doesn't carry it itself. Something like\r\n```ts\r\ninterface MyType {\r\n    prop: number;\r\n    label: number;\r\n    code: number\r\n}\r\n\r\nclass MyClass extends Base<MyType> {\r\n    // Error: Index signature is missing from MyType\r\n}\r\n```\r\n\r\nI don't want to put the index signature on MyType because destructuring `entity` won't output an error when the property doesn't exist:\r\n```ts\r\nconst {id} = this.entity // oops, no error\r\n```\r\nwhich is a critical feature for me.\r\n\r\nI don't want to remove the index signature from the constraint because the base class completely revolves around it and I would lose a lot of type safety.\r\n\r\nIs there something I missed? Should we have some new language feature to solve this issue?\r\n\r\n(Now that I think of it I suppose it's a generic assignability issue between types, not restricted of type constraints, and it's not solved by #7029 since it's only about actual litterals, not types)"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/247690872","html_url":"https://github.com/Microsoft/TypeScript/issues/10941#issuecomment-247690872","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/10941","id":247690872,"user":{"login":"Pajn","id":817422,"avatar_url":"https://avatars.githubusercontent.com/u/817422?v=3","gravatar_id":"","url":"https://api.github.com/users/Pajn","html_url":"https://github.com/Pajn","followers_url":"https://api.github.com/users/Pajn/followers","following_url":"https://api.github.com/users/Pajn/following{/other_user}","gists_url":"https://api.github.com/users/Pajn/gists{/gist_id}","starred_url":"https://api.github.com/users/Pajn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pajn/subscriptions","organizations_url":"https://api.github.com/users/Pajn/orgs","repos_url":"https://api.github.com/users/Pajn/repos","events_url":"https://api.github.com/users/Pajn/events{/privacy}","received_events_url":"https://api.github.com/users/Pajn/received_events","type":"User","site_admin":false},"created_at":"2016-09-16T19:43:30Z","updated_at":"2016-09-16T19:43:30Z","body":"This has been a problem for me as well. I think there needs to be a way to differentiate \"handles objects with any key as long as the value has type T\" and \"requires object that can handle any key as long as the type is T\""}}
{"actor":{"display_login":"Pajn"}}