Title: Inlining definition of NonNullable
Open Graph Title: Inlining definition of NonNullable
X Title: Inlining definition of NonNullable
Description: Apologies if this was submitted already, I could not find anything similar by searching. TypeScript Version: 2.8.1 Search Terms: Existential types, undefined, Exclude, Required, NonNullable, in keyof Code type OnlyPresentV1
Open Graph Description: Apologies if this was submitted already, I could not find anything similar by searching. TypeScript Version: 2.8.1 Search Terms: Existential types, undefined, Exclude, Required, NonNullable, in key...
X Description: Apologies if this was submitted already, I could not find anything similar by searching. TypeScript Version: 2.8.1 Search Terms: Existential types, undefined, Exclude, Required, NonNullable, in key...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/23046
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inlining definition of NonNullable\u003cT> results in different behavior","articleBody":"Apologies if this was submitted already, I could not find anything similar by searching.\r\n\r\n**TypeScript Version:** 2.8.1\r\n\r\n**Search Terms:** Existential types, undefined, Exclude, Required, NonNullable, in keyof\r\n\r\n**Code**\r\n\r\n```ts\r\ntype OnlyPresentV1\u003cT> = {\r\n [P in keyof T]: NonNullable\u003cT[P]>\r\n};\r\n\r\n// should pass, and it does\r\nconst Test_1: OnlyPresentV1\u003c{test: string}> = {test: \"asd\"};\r\n// should fail, and it does\r\nconst Test_2: OnlyPresentV1\u003c{test: string}> = {test: undefined};\r\n// should pass, and it does\r\nconst Test_3: OnlyPresentV1\u003c{test: string | undefined}> = {test: \"asd\"};\r\n// should fail, and it does\r\nconst Test_4: OnlyPresentV1\u003c{test: string | undefined}> = {test: undefined};\r\n\r\ntype OnlyPresentV2\u003cT> = {\r\n [P in keyof T]: T[P] extends null | undefined ? never : T[P] \r\n};\r\n\r\n// should pass, and it does\r\nconst Test_5: OnlyPresentV2\u003c{test: string}> = {test: \"asd\"};\r\n// should fail, and it does\r\nconst Test_6: OnlyPresentV2\u003c{test: string}> = {test: undefined};\r\n// should pass, and it does\r\nconst Test_7: OnlyPresentV2\u003c{test: string | undefined}> = {test: \"asd\"};\r\n// should fail, but it doesn't!\r\nconst Test_8: OnlyPresentV2\u003c{test: string | undefined}> = {test: undefined};\r\n```\r\n\r\n**Expected behavior:**\r\nI noted down what my expectations are above each case.\r\nI expected that inlining the definition of NonNullable would be the same as using the type.\r\n\r\n**Actual behavior:**\r\nBehavior is different, but definitions are essentially the same?\r\n\r\n**Playground Link:** https://goo.gl/fWzwzA (shortend it because it was really long) Enabled all strictness checks I could\r\n\r\n**Related Issues:** Could not find any","author":{"url":"https://github.com/farnoy","@type":"Person","name":"farnoy"},"datePublished":"2018-03-31T19:55:55Z","url":"https://github.com/microsoft/TypeScript/issues/23046"}
| 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:d53a7a1d-48d9-c977-6cf7-dca80ad17603 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B9E2:2C4BED:91AC26:BAB718:6B00ED4C |
| html-safe-nonce | 4d2dc388760960e917379baf6bd84698870191925c82f9f113ceaa047332118a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOUUyOjJDNEJFRDo5MUFDMjY6QkFCNzE4OjZCMDBFRDRDIiwidmlzaXRvcl9pZCI6Ijg1Nzg0OTAyNzU0Nzc5MDg4MTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5a9332cbcde94b2a793c6e4ef4fc132025e69c9370de695ac9850468bd9367a7 |
| hovercard-subject-tag | issue:310267385 |
| 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/23046/issue_layout |
| twitter:image | https://opengraph.githubassets.com/482ba7aa8662c322c454b0099f632a89ddcab52eebb2ccf9b0abb0df2c7e13ab/microsoft/TypeScript/issues/23046 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/482ba7aa8662c322c454b0099f632a89ddcab52eebb2ccf9b0abb0df2c7e13ab/microsoft/TypeScript/issues/23046 |
| og:image:alt | Apologies if this was submitted already, I could not find anything similar by searching. TypeScript Version: 2.8.1 Search Terms: Existential types, undefined, Exclude, Required, NonNullable, in key... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | farnoy |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width