Title: OptionalPropNames
Open Graph Title: OptionalPropNames
X Title: OptionalPropNames
Description: TypeScript Version: 2.8.0-dev.20180216 Code // Type-level filters to extract just the required or optional properties of a type // Defns from https://github.com/Microsoft/TypeScript/pull/21919#issuecomment-365491689 type OptionalPropName...
Open Graph Description: TypeScript Version: 2.8.0-dev.20180216 Code // Type-level filters to extract just the required or optional properties of a type // Defns from https://github.com/Microsoft/TypeScript/pull/21919#issu...
X Description: TypeScript Version: 2.8.0-dev.20180216 Code // Type-level filters to extract just the required or optional properties of a type // Defns from https://github.com/Microsoft/TypeScript/pull/21919#issu...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/21989
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"OptionalPropNames\u003cT>: unexpected result in conditional type","articleBody":"**TypeScript Version:** 2.8.0-dev.20180216\r\n\r\n**Code**\r\n\r\n```ts\r\n// Type-level filters to extract just the required or optional properties of a type\r\n// Defns from https://github.com/Microsoft/TypeScript/pull/21919#issuecomment-365491689\r\ntype OptionalPropNames\u003cT> = { [P in keyof T]: undefined extends T[P] ? P : never }[keyof T];\r\ntype RequiredPropNames\u003cT> = { [P in keyof T]: undefined extends T[P] ? never : P }[keyof T];\r\ntype OptionalProps\u003cT> = { [P in OptionalPropNames\u003cT>]: T[P] };\r\ntype RequiredProps\u003cT> = { [P in RequiredPropNames\u003cT>]: T[P] };\r\n\r\n// Let's extract just the optional property names in a type\r\ntype PropNames = OptionalPropNames\u003c{req: string, opt?: number}>; // Names = \"opt\" | undefined\r\n```\r\n\r\n**Expected behavior:**\r\n`PropNames = \"opt\"`\r\n\r\n**Actual behavior:**\r\n`PropNames = \"opt\" | undefined`. How did that `undefined` get in there?\r\n\r\n**Related Issues:**\r\nNoticed this while writing up #21988, but wasn't sure if the cause was related or not.\r\n\r\nThe `RequiredProps` and `OptionalProps` definitions come from https://github.com/Microsoft/TypeScript/pull/21919#issuecomment-365491689\r\n","author":{"url":"https://github.com/yortus","@type":"Person","name":"yortus"},"datePublished":"2018-02-16T09:10:55Z","url":"https://github.com/microsoft/TypeScript/issues/21989"}
| 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:03ef2b54-840a-c540-c3fc-149a0e1b59aa |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 859C:6FCC9:91C96C:C63F7A:6B053B6E |
| html-safe-nonce | a4fb93d09d94711dcb95c27f14dc9639ef12f78d96857fdb4cf3935113cffcef |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NTlDOjZGQ0M5OjkxQzk2QzpDNjNGN0E6NkIwNTNCNkUiLCJ2aXNpdG9yX2lkIjoiNDQ0MzE1OTEyNzA5NDgwMzMxMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d61fb274621e0ec7803c9eb9b83de5826ca09fe43534281a5790a60692a9f013 |
| hovercard-subject-tag | issue:297719407 |
| 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/21989/issue_layout |
| twitter:image | https://opengraph.githubassets.com/78d0f5ea74d0a7fb58c7c0b1a057160c73b4a1c321388e90b59ac3e5dc175cf7/microsoft/TypeScript/issues/21989 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/78d0f5ea74d0a7fb58c7c0b1a057160c73b4a1c321388e90b59ac3e5dc175cf7/microsoft/TypeScript/issues/21989 |
| og:image:alt | TypeScript Version: 2.8.0-dev.20180216 Code // Type-level filters to extract just the required or optional properties of a type // Defns from https://github.com/Microsoft/TypeScript/pull/21919#issu... |
| 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 | 854d880890b5e847b3fce9d1b31f032107baeddeebad2aa379c48aa4f1451f6b |
| 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 | 220e980097d94ce616d5d11fbd5316d208e3fc93 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width