Title: Add support for literal type subtraction · Issue #12215 · microsoft/TypeScript · GitHub
Open Graph Title: Add support for literal type subtraction · Issue #12215 · microsoft/TypeScript
X Title: Add support for literal type subtraction · Issue #12215 · microsoft/TypeScript
Description: Now we have Mapped Types and keyof, we could add a subtraction operator that only works on literal types: type Omit
Open Graph Description: Now we have Mapped Types and keyof, we could add a subtraction operator that only works on literal types: type Omit
X Description: Now we have Mapped Types and keyof, we could add a subtraction operator that only works on literal types: type Omit<T, K extends keyof T> = { [P in keyof T - K]: T[P]; }; type Overwrite<T,...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/12215
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add support for literal type subtraction ","articleBody":"Now we have [Mapped Types](https://github.com/Microsoft/TypeScript/pull/12114) and [keyof](https://github.com/Microsoft/TypeScript/pull/11929), we could add a subtraction operator that only works on literal types:\r\n\r\n```typescript\r\ntype Omit\u003cT, K extends keyof T\u003e = {\r\n [P in keyof T - K]: T[P];\r\n};\r\n\r\ntype Overwrite\u003cT, K\u003e = K \u0026 {\r\n [P in keyof T - keyof K]: T[P];\r\n};\r\n\r\ntype Item1 = { a: string, b: number, c: boolean };\r\ntype Item2 = { a: number };\r\n\r\ntype T1 = Omit\u003cItem1, \"a\"\u003e // { b: number, c: boolean };\r\ntype T2 = Overwrite\u003cItem1, Item2\u003e // { a: number, b: number, c: boolean };\r\n```","author":{"url":"https://github.com/alinhle","@type":"Person","name":"alinhle"},"datePublished":"2016-11-14T09:10:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":90},"url":"https://github.com/12215/TypeScript/issues/12215"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b9d0786a-d4d2-6cd3-f589-f4c6144a365c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CDF4:3D83D7:2927159:37602CE:6A651534 |
| html-safe-nonce | 9c7a4b49681d2cf44ec0e5f0a3e1b2775fc837061ee7fd8bbf73e461e8c7adf4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDREY0OjNEODNENzoyOTI3MTU5OjM3NjAyQ0U6NkE2NTE1MzQiLCJ2aXNpdG9yX2lkIjoiNjEzMTE5MDcwMTU4OTA3NTI1MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | df560d0805a4f901742bea639db34db0d73e77dbc0317675b6eb5494216cd5ab |
| hovercard-subject-tag | issue:189061114 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/12215/issue_layout |
| twitter:image | https://opengraph.githubassets.com/70477df6dbee0fabae2ec07645003f6121e182cab62ef8a9809a04dfc55a030d/microsoft/TypeScript/issues/12215 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/70477df6dbee0fabae2ec07645003f6121e182cab62ef8a9809a04dfc55a030d/microsoft/TypeScript/issues/12215 |
| og:image:alt | Now we have Mapped Types and keyof, we could add a subtraction operator that only works on literal types: type Omit |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alinhle |
| hostname | github.com |
| expected-hostname | github.com |
| None | 52c76df668885aaff23b50bdca1fa1ea44ac9c1553e888ebc70ff1e4daa4625b |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 309153364422b3c499922d1a2a6404910a58ed8e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width