Title: Inconsistent behaviour of `-?` · Issue #59948 · microsoft/TypeScript · GitHub
Open Graph Title: Inconsistent behaviour of `-?` · Issue #59948 · microsoft/TypeScript
X Title: Inconsistent behaviour of `-?` · Issue #59948 · microsoft/TypeScript
Description: 🔎 Search Terms optional mapped type 🕗 Version & Regression Information This changed between versions 5.4.5 and 5.5.4 ⏯ Playground Link https://www.typescriptlang.org/play/?exactOptionalPropertyTypes=true#code/C4TwDgpgBA8mwEsD2A7AhgGwCpIK...
Open Graph Description: 🔎 Search Terms optional mapped type 🕗 Version & Regression Information This changed between versions 5.4.5 and 5.5.4 ⏯ Playground Link https://www.typescriptlang.org/play/?exactOptionalPropertyType...
X Description: 🔎 Search Terms optional mapped type 🕗 Version & Regression Information This changed between versions 5.4.5 and 5.5.4 ⏯ Playground Link https://www.typescriptlang.org/play/?exactOptionalProperty...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/59948
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inconsistent behaviour of `-?`","articleBody":"### 🔎 Search Terms\n\noptional mapped type\n\n### 🕗 Version & Regression Information\n\n- This changed between versions 5.4.5 and 5.5.4\n\n\n### ⏯ Playground Link\n\nhttps://www.typescriptlang.org/play/?exactOptionalPropertyTypes=true#code/C4TwDgpgBA8mwEsD2A7AhgGwCpIKouRQHUFgALfAEwgDMEUJKAeLAPigF4oBvAKCgFQA2gGko9KAGsIIJDShYAugC4FUCAA9gEFJQDOUAEoQAxkgBOzEQBoFoxa36DnAfjsjFT5wNVZ7UAB8oAFddWnpGXgBfXl5QSCgASRRtcwBbBEoENG1OWHhCTBx8QhJyKnCGZm4oNBdVPWBzegBzKCj2AHpOnlr6qEbmlDag0Oo6Kva48GgAGVIIc0w8mrqGptbAkLCJxnaoboG0NOh46DQDZNSMrJyIWLOjCD0ARjzjAEdghHNGJivFjdstouj1Vushm0Yo9jHoAEzvCBfH5-eapTCg3poCGbUY7CKUdpAA\n\n### 💻 Code\n\n```ts\ntype OptionalToUnionWithUndefined\u003cT> = {\n [K in keyof T]: T extends Record\u003cK, T[K]>\n ? T[K]\n : T[K] | undefined\n}\n\ntype Intermediate = OptionalToUnionWithUndefined\u003c{ a?: string }> // { a?: string | undefined }\ntype Literal = { a?: string | undefined } // same type as Intermediate\n\ntype Res1 = Required\u003cIntermediate> // { a: string }\ntype Res2 = Required\u003cLiteral> // { a: string | undefined }\n```\n\n\n### 🙁 Actual behavior\n\n`Res1` and `Res2` are different types\n\n### 🙂 Expected behavior\n\nthey should be the same because the inputs are\n\n### Additional information about the issue\n\nThis issue may share the cause with #59902 ","author":{"url":"https://github.com/m-shaka","@type":"Person","name":"m-shaka"},"datePublished":"2024-09-12T08:39:47Z","url":"https://github.com/microsoft/TypeScript/issues/59948"}
| 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:a83dbdd4-0c2d-462d-ad7f-56b1c95b6fce |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9582:143D5D:DC78EF:1244272:6B050821 |
| html-safe-nonce | 6e8567055574fe2fb7c3dba743aa40e8ded1345299f0956dd2f982aa14b8254b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTgyOjE0M0Q1RDpEQzc4RUY6MTI0NDI3Mjo2QjA1MDgyMSIsInZpc2l0b3JfaWQiOiI1ODE3NTA1NDMyOTY4OTU1OTM3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 74417129283aa92542f93bce1f43c0417849da0924d27626a0ea4972d8981997 |
| hovercard-subject-tag | issue:2521743115 |
| 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/59948/issue_layout |
| twitter:image | https://opengraph.githubassets.com/75ac82ef6cd51580f443bf16cc1d7aa7717d631c5933b5fb91621d883a7982b6/microsoft/TypeScript/issues/59948 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/75ac82ef6cd51580f443bf16cc1d7aa7717d631c5933b5fb91621d883a7982b6/microsoft/TypeScript/issues/59948 |
| og:image:alt | 🔎 Search Terms optional mapped type 🕗 Version & Regression Information This changed between versions 5.4.5 and 5.5.4 ⏯ Playground Link https://www.typescriptlang.org/play/?exactOptionalPropertyType... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | m-shaka |
| 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