Title: Allow partial (subset) type matching · Issue #392 · microsoft/TypeScript · GitHub
Open Graph Title: Allow partial (subset) type matching · Issue #392 · microsoft/TypeScript
X Title: Allow partial (subset) type matching · Issue #392 · microsoft/TypeScript
Description: Various libraries have a concept of applying partial updates to an object. For example: http://backbonejs.org/#Model-set http://facebook.github.io/react/docs/component-api.html#setstate Take the following example (to roughly mimic Backbo...
Open Graph Description: Various libraries have a concept of applying partial updates to an object. For example: http://backbonejs.org/#Model-set http://facebook.github.io/react/docs/component-api.html#setstate Take the fo...
X Description: Various libraries have a concept of applying partial updates to an object. For example: http://backbonejs.org/#Model-set http://facebook.github.io/react/docs/component-api.html#setstate Take the fo...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/392
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Allow partial (subset) type matching","articleBody":"Various libraries have a concept of applying partial updates to an object. For example:\n\nhttp://backbonejs.org/#Model-set\nhttp://facebook.github.io/react/docs/component-api.html#setstate\n\nTake the following example (to roughly mimic Backbone)\n\n```\ninterface Person {\n firstName: string\n lastName: string\n phoneNumber: string\n}\n\nvar model = {\n set: function(data: Person) {}\n}\n\nmodel.set({\n phoneNumber: '405-555-1254'\n})\n```\n\nIn this case an error is thrown saying that properties are missing. One solution is to make all of the properties in the interface optional. However, that may not be desirable; I may actually want those properties to be required in other locations and only optional in this specific context. I would like to propose a feature where in a certain context a new type is created on-the-fly based on another type where all properties of the base type are optional. For example:\n\n```\nPerson? => {\n firstName?: string\n lastName?: string\n phoneNumber?: string\n}\n```\n\nand therefore the following would work:\n\n```\nvar model = {\n set: function(data: Person?) {}\n}\n\nmodel.set({\n phoneNumber: '405-555-1254'\n})\n```\n\nI think this would also work particularly well in conjunction with my other suggestion #391 \n\n```\nset: function(data: Person?!) {}\n```\n\nWhere zero or more properties from Person will match but ONLY properties from Person will match.\n","author":{"url":"https://github.com/jbrantly","@type":"Person","name":"jbrantly"},"datePublished":"2014-08-07T18:25:40Z","url":"https://github.com/microsoft/TypeScript/issues/392"}
| 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:65e22ba8-7260-8ab4-b9ed-6b800f60c7e0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8930:1324A5:58BD1F:778A2B:6AFBF311 |
| html-safe-nonce | 063afdf9b17648c2f17594f5248c5dc87dee09ba458d1b1efa5fab3e79efc4ac |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OTMwOjEzMjRBNTo1OEJEMUY6Nzc4QTJCOjZBRkJGMzExIiwidmlzaXRvcl9pZCI6IjUzMzE4OTQ4MDEwMjcyOTgwNjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | fca89dad433d030ad58e58aceb28d7d9403710cb481842034b207727d2714c32 |
| hovercard-subject-tag | issue:39753743 |
| 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/392/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ef3b381b5c18369c83b941bcbb36590c0bc5bcbd9f9314e1fe87b1cae16eea74/microsoft/TypeScript/issues/392 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ef3b381b5c18369c83b941bcbb36590c0bc5bcbd9f9314e1fe87b1cae16eea74/microsoft/TypeScript/issues/392 |
| og:image:alt | Various libraries have a concept of applying partial updates to an object. For example: http://backbonejs.org/#Model-set http://facebook.github.io/react/docs/component-api.html#setstate Take the fo... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jbrantly |
| hostname | github.com |
| expected-hostname | github.com |
| None | fa74413a1d84dac536fcca0740780bcbd3207bafec0e51873b73ff8e8cca032f |
| 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 | b3b5633a74535d9c23385512d534c66c8fde1907 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width