{"action":"opened","issue":{"url":"https://api.github.com/repos/styled-components/styled-components/issues/1683","repository_url":"https://api.github.com/repos/styled-components/styled-components","labels_url":"https://api.github.com/repos/styled-components/styled-components/issues/1683/labels{/name}","comments_url":"https://api.github.com/repos/styled-components/styled-components/issues/1683/comments","events_url":"https://api.github.com/repos/styled-components/styled-components/issues/1683/events","html_url":"https://github.com/styled-components/styled-components/issues/1683","id":313924502,"number":1683,"title":"Improve helper type operators through TypeScript 2.8","user":{"login":"miZyind","id":21041375,"avatar_url":"https://avatars0.githubusercontent.com/u/21041375?v=4","gravatar_id":"","url":"https://api.github.com/users/miZyind","html_url":"https://github.com/miZyind","followers_url":"https://api.github.com/users/miZyind/followers","following_url":"https://api.github.com/users/miZyind/following{/other_user}","gists_url":"https://api.github.com/users/miZyind/gists{/gist_id}","starred_url":"https://api.github.com/users/miZyind/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miZyind/subscriptions","organizations_url":"https://api.github.com/users/miZyind/orgs","repos_url":"https://api.github.com/users/miZyind/repos","events_url":"https://api.github.com/users/miZyind/events{/privacy}","received_events_url":"https://api.github.com/users/miZyind/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-12T23:48:46Z","updated_at":"2018-04-12T23:48:46Z","closed_at":null,"author_association":"NONE","body":"At that time before TypeScript 2.8, there wasn't a clean solution about how to \"Omit\" some keys from an existing interface.\r\n\r\nBut now we can use the new conditional type \"Exclude\" to improve type safety!\r\n\r\nWe can drop these helper type operators and rewrite some definition:\r\n```typescript\r\n// Line 73 ~ 76 in node_modules/styled-components/typings/styled-components.d.ts\r\n// Helper type operators\r\ntype Diff<T extends string, U extends string> = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T];\r\ntype Omit<T, K extends keyof T> = Pick<T, Diff<keyof T, K>>;\r\ntype WithOptionalTheme<P extends { theme?: T; }, T> = Omit<P, \"theme\"> & { theme?: T; };\r\n```\r\n\r\nAfter:\r\n```typescript\r\n// Helper type operators\r\ntype WithOptionalTheme<P extends { theme?: T; }, T> = Exclude<P, \"theme\"> & { theme?: T; };\r\n```\r\n\r\nAnd now we get the benefit (Go to current props' definition & props' type checking)!\r\n![improve](https://user-images.githubusercontent.com/21041375/38709653-b4f0ef44-3eee-11e8-9588-15e2a016c53e.png)"}}
{"actor":{"display_login":"miZyind"}}