Title: when merging a generic object type with new optional properties, these properties are not type checked · Issue #36637 · microsoft/TypeScript · GitHub
Open Graph Title: when merging a generic object type with new optional properties, these properties are not type checked · Issue #36637 · microsoft/TypeScript
X Title: when merging a generic object type with new optional properties, these properties are not type checked · Issue #36637 · microsoft/TypeScript
Description: TypeScript Version: Nightly Search Terms: generic spread optional property Code interface Test { readonly hi?: string[] } function test
Open Graph Description: TypeScript Version: Nightly Search Terms: generic spread optional property Code interface Test { readonly hi?: string[] } function test
X Description: TypeScript Version: Nightly Search Terms: generic spread optional property Code interface Test { readonly hi?: string[] } function test<T extends object>(value: T): Test { return { ...value, ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/36637
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"when merging a generic object type with new optional properties, these properties are not type checked","articleBody":"**TypeScript Version:** Nightly\r\n\r\n**Search Terms:** generic spread optional property\r\n\r\n**Code**\r\n\r\n```ts\r\ninterface Test {\r\n readonly hi?: string[]\r\n}\r\n\r\nfunction test\u003cT extends object>(value: T): Test {\r\n return { ...value, hi: true }\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\nThis should fail to type check.\r\n\r\n**Actual behavior:**\r\nIt passes. Interestingly, changing any of the following causes it to fail:\r\n* Make the `hi` property non-optional\r\n* Replace `T` with `object`.\r\n\r\n**Related Issues:** Not sure\r\n","author":{"url":"https://github.com/aquark","@type":"Person","name":"aquark"},"datePublished":"2020-02-05T19:05:48Z","url":"https://github.com/microsoft/TypeScript/issues/36637"}
| 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:d14fd868-d663-9bed-8827-2bec6eddb404 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8BB6:19D48:1331C:17E5F:6B00F095 |
| html-safe-nonce | d66bf912774ab1cd4eb59cb5f9dd406b20d334d53e1ca3f4334b424031c1d44b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QkI2OjE5RDQ4OjEzMzFDOjE3RTVGOjZCMDBGMDk1IiwidmlzaXRvcl9pZCI6IjIyNjY0Nzk5Mjc3OTg4NTM3ODEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 658e39f5f7f08354c84116c42c1a2bc9d040b627d586dd614feb31835e0d1e63 |
| hovercard-subject-tag | issue:560569194 |
| 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/36637/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5a17c4ea3c1fcf6a2d84bf0ba1b1a90e364d87e56d121bcb5e585586c34d1bc8/microsoft/TypeScript/issues/36637 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5a17c4ea3c1fcf6a2d84bf0ba1b1a90e364d87e56d121bcb5e585586c34d1bc8/microsoft/TypeScript/issues/36637 |
| og:image:alt | TypeScript Version: Nightly Search Terms: generic spread optional property Code interface Test { readonly hi?: string[] } function test |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | aquark |
| 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