Title: Exclude
Open Graph Title: Exclude
X Title: Exclude
Description: TypeScript Version: 2.8.0-dev.20180213 Search Terms: Exclude Diff Code // Old 'Diff' type, superseded since #21847 by new 'Exclude' builtin type type Diff
Open Graph Description: TypeScript Version: 2.8.0-dev.20180213 Search Terms: Exclude Diff Code // Old 'Diff' type, superseded since #21847 by new 'Exclude' builtin type type Diff
X Description: TypeScript Version: 2.8.0-dev.20180213 Search Terms: Exclude Diff Code // Old 'Diff' type, superseded since #21847 by new 'Exclude' builtin type type Diff<T extends string, U ext...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/21929
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Exclude\u003cT, U> type not working like Diff\u003cT, U>","articleBody":"**TypeScript Version:** 2.8.0-dev.20180213\r\n\r\n**Search Terms:** \r\n- Exclude\r\n- Diff\r\n\r\n**Code**\r\n\r\n```ts\r\n// Old 'Diff' type, superseded since #21847 by new 'Exclude' builtin type\r\ntype Diff\u003cT extends string, U extends string>\r\n = ({[P in T]: P } & {[P in U]: never } & { [x: string]: never })[T];\r\n\r\ntype NonFooKeys1\u003cT extends object> = Diff\u003ckeyof T, 'foo'>; // remove 'foo' using Diff\r\ntype NonFooKeys2\u003cT extends object> = Exclude\u003ckeyof T, 'foo'>; // remove 'foo' using Exclude\r\n\r\ntype Test1 = NonFooKeys1\u003c{foo: 1, bar: 2, baz: 3}>; // Test1 is \"bar\" | \"baz\"\r\ntype Test2 = NonFooKeys2\u003c{foo: 1, bar: 2, baz: 3}>; // Test2 is \"foo\" | \"bar\" | \"baz\"\r\n```\r\n\r\n**Expected behavior:**\r\n`Test2` should be `\"bar\" | \"baz\"`, the same as `Test1`.\r\n\r\n**Actual behavior:**\r\nThe key `\"foo\"` was not removed from `keyof T` when using the `Exclude` builtin type.\r\n\r\n**Related Issues:**\r\n- [Predefined conditional types #21847](https://github.com/Microsoft/TypeScript/pull/21847)\r\n- [Add Omit\u003cT,K> and Diff\u003cT,U> to lib.d.ts #19569](https://github.com/Microsoft/TypeScript/issues/19569)\r\n","author":{"url":"https://github.com/yortus","@type":"Person","name":"yortus"},"datePublished":"2018-02-14T02:36:04Z","url":"https://github.com/microsoft/TypeScript/issues/21929"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:e9cf3250-3a3e-6b39-2468-68f481c0af12 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AD80:2D2F2F:9AC69B:C9E941:6B00E184 |
| html-safe-nonce | 8902b1817a53a2bbbba60b4fd6a04a5563eac2d3ab4479b5e3325853943164a3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRDgwOjJEMkYyRjo5QUM2OUI6QzlFOTQxOjZCMDBFMTg0IiwidmlzaXRvcl9pZCI6IjY0NzUyNTQxOTY2MDUwODQwMzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ef874c243fc64ccfbe2b2423dab71e1e64d7aa4eb17382bff50070b1b5ca3a44 |
| hovercard-subject-tag | issue:296956968 |
| 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/21929/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ae0aa83d57540e552b1f696811948215cabf1fe2e1ef94732e13ce1d7bb40853/microsoft/TypeScript/issues/21929 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ae0aa83d57540e552b1f696811948215cabf1fe2e1ef94732e13ce1d7bb40853/microsoft/TypeScript/issues/21929 |
| og:image:alt | TypeScript Version: 2.8.0-dev.20180213 Search Terms: Exclude Diff Code // Old 'Diff' type, superseded since #21847 by new 'Exclude' builtin type type Diff |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | yortus |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| 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 | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width