René's URL Explorer Experiment


Title: Add spread/rest higher-order types operator · Issue #10727 · microsoft/TypeScript · GitHub

Open Graph Title: Add spread/rest higher-order types operator · Issue #10727 · microsoft/TypeScript

X Title: Add spread/rest higher-order types operator · Issue #10727 · microsoft/TypeScript

Description: The spread type is a new type operator that types the TC39 stage 3 object spread operator. Its counterpart, the difference type, will type the proposed object rest destructuring operator. The spread type { ...A, ...B } combines the prope...

Open Graph Description: The spread type is a new type operator that types the TC39 stage 3 object spread operator. Its counterpart, the difference type, will type the proposed object rest destructuring operator. The sprea...

X Description: The spread type is a new type operator that types the TC39 stage 3 object spread operator. Its counterpart, the difference type, will type the proposed object rest destructuring operator. The sprea...

Opengraph URL: https://github.com/microsoft/TypeScript/issues/10727

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add spread/rest higher-order types operator","articleBody":"The spread type is a new type operator that types the [TC39 stage 3 object spread operator](https://github.com/sebmarkbage/ecmascript-rest-spread). Its counterpart, the difference type, will type the proposed object rest destructuring operator. The spread type `{ ...A, ...B }` combines the properties, but not the call or construct signatures, of entities A and B.\n\nThe pull request is at #11150. The original issue for spread/rest types is #2103. Note that this proposal deviates from the specification by keeping all properties except methods, not just own enumerable ones.\n## Proposal syntax\n\nThe type syntax in this proposal differs from the type syntax as implemented in order to treat spread as a binary operator. Three rules are needed to convert the `{ ...spread1, ...spread2 }` syntax to binary syntax `spread1 ... spread2`.\n1. `{ ...spread }` becomes `{} ... spread`.\n2. `{ a, b, c, ...d}` becomes `{a, b, c} ... d`\n3. Multiple spreads inside an object literal are treated as sequences of binary spreads: `{ a, b, c, ...d, ...e, f, g}` becomes `{a, b, c} ... d ... e ... { f, g }`.\n## Type Relationships\n- Identity: `A ... A ... A` is equivalent to `A ... A` and `A ... A` is equivalent to `{} ... A`.\n- Commutativity: `A ... B` is _not_ equivalent to `B ... A`. Properties of `B` overwrite properties of `A` with the same name in `A ... B`.\n- Associativity: `(A ... B) ... C` is equivalent to `A ... (B ... C)`. `...` is right-associative.\n- Distributivity: Spread is distributive over `|`, so `A ... (B | C)` is equivalent to `A ... B | A ... C`.\n## Assignment compatibility\n- `A ... B` is assignable to `X` if the properties and index signatures of `A ... B` are assignable to those of `X`, and `X` has no call or construct signatures.\n- `X` is assignable to `A ... B` if the properties and index signatures of `X` are assignable to those of `A ... B`.\n### Type parameters\n\nA spread type containing type parameters is assignable to another spread type if the type if the source and target types are both of the form `T ... { some, object, type }` and both source and target have the same type parameter and the source object type is assignable to the target object type.\n### Type inference\n\nSpread types are not type inference targets.\n## Properties and index signatures\n\nIn the following definitions, 'property' means either a property or a get accessor.\n\nThe type `A ... B` has a property `P` if \n1. `A` has a property `P` or `B` has a property `P`, and\n2. Either `A.P` or `B.P` is not a method. \n\nIn this case `(A ... B).P` has the type \n1. Of `B.P` if `B.P` is not optional.\n2. Of `A.P | B.P` if `B.P` is optional and `A` has a property `P`.\n3. Of `A.P` otherwise.\n\n`private`, `protected` and `readonly` behave the same way as optionality except that if `A.P` or `B.P` is `private`, `protected` or `readonly`, then `(A ...B).P` is `private`, `protected` or `readonly`, respectively.\n## Index signatures\n\nThe type `A ... B` has an index signature if `A` has an index signature and `B` has an index signature. The index signature's type is the union of the two index signatures' types.\n## Call and Construct signatures\n\n`A ... B` has no call signatures and no construct signatures, since these are not properties.\n## Precedence\n\nPrecedence of `...` is higher than `\u0026` and `|`. Since the language syntax is that of object type literals, precedence doesn't matter since the braces act as boundaries of the spread type.\n## Examples\n\nTaken from the [TC39 proposal](https://github.com/sebmarkbage/ecmascript-rest-spread/blob/master/Spread.md) and given types.\n### Shallow Clone (excluding prototype)\n\n``` ts\nlet aClone: { ...A } = { ...a };\n```\n### Merging Two Objects\n\n``` ts\nlet ab: { ...A, ...B } = { ...a, ...b };\n```\n### Overriding Properties\n\n``` ts\nlet aWithOverrides: { ...A, x: number, y: number } = { ...a, x: 1, y: 2 };\n// equivalent to\nlet aWithOverrides: { ...A, ...{ x: number, y: number } } = { ...a, ...{ x: 1, y: 2 } };\n```\n### Default Properties\n\n``` ts\nlet aWithDefaults: { x: number, y: number, ...A } = { x: 1, y: 2, ...a };\n```\n### Multiple Merges\n\n``` ts\n// Note: getters on a are executed twice\nlet xyWithAandB: { x: number, ...A, y: number, ...B, ...A } = { x: 1, ...a, y: 2, ...b, ...a };\n// equivalent to\nlet xyWithAandB: { x: number, y: number, ...B, ...A } = { x: 1, ...a, y: 2, ...b, ...a };\n```\n### Getters on the Object Initializer\n\n``` ts\n// Does not throw because .x isn't evaluated yet. It's defined.\nlet aWithXGetter: { ...A, x: never } = { ...a, get x() { throw new Error('not thrown yet') } };\n```\n### Getters in the Spread Object\n\n``` ts\n// Throws because the .x property of the inner object is evaluated when the\n// property value is copied over to the surrounding object initializer.\nlet runtimeError: { ...A, x: never } = { ...a, ...{ get x() { throw new Error('thrown now') } } };\n```\n### Setters Are Not Executed When They're Redefined\n\n``` ts\nlet z: { x: number } = { set x() { throw new Error(); }, ...{ x: 1 } }; // No error\n```\n### Null/Undefined Are Ignored\n\n``` ts\nlet emptyObject: {} = { ...null, ...undefined }; // no runtime error\n```\n### Updating Deep Immutable Object\n\n``` ts\nlet newVersion: { ...A, name: string, address: { address, zipCode: string }, items: { title: string }[] } = {\n  ...previousVersion,\n  name: 'New Name', // Override the name property\n  address: { ...previousVersion.address, zipCode: '99999' } // Update nested zip code\n  items: [...previousVersion.items, { title: 'New Item' }] // Add an item to the list of items\n};\n```\n\nNote: If `A = { name: string, address: { address, zipCode: string }, items: { title: string }[] }`, then the type of newVersion is equivalent to `A`\n# Rest types\n\nThe difference type is the opposite of the spread type. It types the TC39 stage 3 object-rest destructuring operator.  The difference type `rest(T, a, b, c)` represents the type `T` after the properties `a`, `b` and `c` have been removed, as well as call signatures and construct signatures. \n\nA short example illustrates the way this type is used:\n\n``` ts\n/** JavaScript version */\nfunction removeX(o) {\n  let { x, ...rest } = o;\n  return rest;\n}\n\n/** Typescript version */\nfunction removeX\u003cT extends { x: number, y: number }\u003e(o: T): rest(T, x) {\n  let { x, ...rest }: T = o;\n  return rest;\n}\n```\n## Type Relationships\n- `rest(A)` is not equivalent to `A` because it is missing call and construct signatures. \n- `rest(rest(A))` is equivalent to `rest(A)`. \n- `rest(rest(A, a), b)` is equivalent to `rest(rest(A, b), a)` and `rest(A, a, b)`.\n- `rest(A | B, a)` is equivalent to `rest(A, a) | rest(B, a)`.\n## Assignment compatibility\n- `rest(T, x)` is not assignable to `T`.\n- `T` is assignable to `rest(T, x)` because `T` has more properties and signatures.\n## Properties and index signatures\n\nThe type `rest(A, P)` removes `P` from `A` if it exists. Otherwise, it does nothing.\n## Call and Construct signatures\n\n`rest(A)` does not have call or construct signatures.\n## Precedence\n\nDifference types have similar precedence to `-` in the expression grammar, particularly compared to `\u0026` and `|`. TODO: Find out what this precedence is.\n","author":{"url":"https://github.com/sandersn","@type":"Person","name":"sandersn"},"datePublished":"2016-09-06T18:00:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":86},"url":"https://github.com/10727/TypeScript/issues/10727"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:1802aae4-2d0e-c8f8-421e-3536749b6564
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBE84:34E523:3CDE23:528ACA:6A4D39A9
html-safe-nonce45816467852e856507347a3ebdc5c9922eeef8b1622a2b2cc294b37ff0effbbf
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRTg0OjM0RTUyMzozQ0RFMjM6NTI4QUNBOjZBNEQzOUE5IiwidmlzaXRvcl9pZCI6Ijg2MjYwMDg1MTM3Mjg4MjE2NzMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac6e23d51789ce7d2f5d3f5f44c3be3c68ecd7b0537795fc9a139e9a7d5bc648a2
hovercard-subject-tagissue:175311249
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/10727/issue_layout
twitter:imagehttps://opengraph.githubassets.com/49bfc68f3021227273005a4ae263b08fa3d73c1595771a03499a085369053a28/microsoft/TypeScript/issues/10727
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/49bfc68f3021227273005a4ae263b08fa3d73c1595771a03499a085369053a28/microsoft/TypeScript/issues/10727
og:image:altThe spread type is a new type operator that types the TC39 stage 3 object spread operator. Its counterpart, the difference type, will type the proposed object rest destructuring operator. The sprea...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesandersn
hostnamegithub.com
expected-hostnamegithub.com
None92571a8944142227b7e19cd10918b1ddd06e5066c1ad5bc7e4769cf6140a87e6
turbo-cache-controlno-preview
go-importgithub.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git
octolytics-dimension-user_id6154722
octolytics-dimension-user_loginmicrosoft
octolytics-dimension-repository_id20929025
octolytics-dimension-repository_nwomicrosoft/TypeScript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id20929025
octolytics-dimension-repository_network_root_nwomicrosoft/TypeScript
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release56fc8347865a14e2ec811533d68f929cf4e0ec19
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/10727#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F10727
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F10727
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=microsoft%2FTypeScript
Reloadhttps://github.com/microsoft/TypeScript/issues/10727
Reloadhttps://github.com/microsoft/TypeScript/issues/10727
Reloadhttps://github.com/microsoft/TypeScript/issues/10727
Please reload this pagehttps://github.com/microsoft/TypeScript/issues/10727
microsoft https://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Notifications https://github.com/login?return_to=%2Fmicrosoft%2FTypeScript
Fork 13.5k https://github.com/login?return_to=%2Fmicrosoft%2FTypeScript
Star 109k https://github.com/login?return_to=%2Fmicrosoft%2FTypeScript
Code https://github.com/microsoft/TypeScript
Issues 5k+ https://github.com/microsoft/TypeScript/issues
Pull requests 33 https://github.com/microsoft/TypeScript/pulls
Actions https://github.com/microsoft/TypeScript/actions
Projects https://github.com/microsoft/TypeScript/projects
Models https://github.com/microsoft/TypeScript/models
Wiki https://github.com/microsoft/TypeScript/wiki
Security and quality 0 https://github.com/microsoft/TypeScript/security
Insights https://github.com/microsoft/TypeScript/pulse
Code https://github.com/microsoft/TypeScript
Issues https://github.com/microsoft/TypeScript/issues
Pull requests https://github.com/microsoft/TypeScript/pulls
Actions https://github.com/microsoft/TypeScript/actions
Projects https://github.com/microsoft/TypeScript/projects
Models https://github.com/microsoft/TypeScript/models
Wiki https://github.com/microsoft/TypeScript/wiki
Security and quality https://github.com/microsoft/TypeScript/security
Insights https://github.com/microsoft/TypeScript/pulse
Add spread/rest higher-order types operatorhttps://github.com/microsoft/TypeScript/issues/10727#top
RevisitAn issue worth coming back tohttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Revisit%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
Backloghttps://github.com/microsoft/TypeScript/milestone/29
https://github.com/sandersn
sandersnhttps://github.com/sandersn
on Sep 6, 2016https://github.com/microsoft/TypeScript/issues/10727#issue-175311249
TC39 stage 3 object spread operatorhttps://github.com/sebmarkbage/ecmascript-rest-spread
#11150https://github.com/microsoft/TypeScript/pull/11150
#2103https://github.com/microsoft/TypeScript/issues/2103
TC39 proposalhttps://github.com/sebmarkbage/ecmascript-rest-spread/blob/master/Spread.md
RevisitAn issue worth coming back tohttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Revisit%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
BacklogNo due datehttps://github.com/microsoft/TypeScript/milestone/29
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.