René's URL Explorer Experiment


Title: Proposal: Support spread operator for arrays and tuples in function calls · Issue #5296 · microsoft/TypeScript · GitHub

Open Graph Title: Proposal: Support spread operator for arrays and tuples in function calls · Issue #5296 · microsoft/TypeScript

X Title: Proposal: Support spread operator for arrays and tuples in function calls · Issue #5296 · microsoft/TypeScript

Description: Currently, Typescript does not support all uses of Ecmascript's spread operator. Specifically, in function calls, Typescript only supports spreading array arguments that match rest parameters. #4130 is a recent mention of this limitation...

Open Graph Description: Currently, Typescript does not support all uses of Ecmascript's spread operator. Specifically, in function calls, Typescript only supports spreading array arguments that match rest parameters. #413...

X Description: Currently, Typescript does not support all uses of Ecmascript's spread operator. Specifically, in function calls, Typescript only supports spreading array arguments that match rest parameters. ...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Proposal: Support spread operator for arrays and tuples in function calls","articleBody":"Currently, Typescript does not support all uses of Ecmascript's spread operator. Specifically, in function calls, Typescript only supports spreading array arguments that match rest parameters. #4130 is a recent mention of this limitation. I propose two ways of addressing this limitation in function calls: \n1. Support array arguments with the spread operator that do not match rest parameters.\n2. Support tuple arguments with the spread operator.\n\nAlthough (2) is cleaner from a type checker's point of view, I believe that (1) is more useful because it can type more of the uses that Javascript programmers are accustomed to writing. Of course, both proposals could be implemented.\n# Proposal 1: Spread operator supports array arguments\n\nThe spread operator may be used with the last array argument of a function call, even when that argument doesn't match a rest parameter in the function definition. However, the parameters must all be optional and of the same type. The type must match the element type of the array.\nFor example, \n\n``` ts\nfunction f(s: string, a?: number, b?: number,  ...rest: number[]) {\n    // ...\n}\nfunction g(s: string, a?: number, b?: number) {\n    // ...\n}\n// legal\nlet long: number[] = [1,2,3];\nlet medium: number[] = [1,2];\nlet short: number[] = [1];\nlet empty: number[] = [];\nf(\"foo\", ...long); // and medium, short and empty\nf(\"foo\", ...long, 1, ...long); // and medium, short and empty\ng(\"foo\", ...long); // and medium, short and empty\n// illegal\nf(...[\"foo\", 1, 2]); // array of type (number | string)[] doesn't match any parameter type\ng(\"foo\", ...long, 1); // 1 doesn't match any parameter\ng(\"foo\", ...empty, 1); // 1 would match, but the compiler can't tell\n```\n\nThe checker consumes all parameters that match the array type after the spread operator is used, until \n1. A non-matching type is encountered, causing an error.\n2. The end of the parameter list is encountered, succeeding.\n3. A rest parameter is encountered, succeeding if the rest parameter's array type matches the spread argument's array type.\n4. TODO: These rules don't account for trailing arguments that also match a rest parameter.\n\nAt runtime the spread operator has EcmaScript semantics. Basically, `undefined` if the array is too short, and extra arguments are ignored.\n# Proposal 2: Spread operator supports tuple arguments\n\nThe spread operator may be used with a tuple argument at any position in a function call. Extra members of the tuple will even match rest parameters if the tuple is long enough.\n\n``` ts\nfunction f(s: string, a: number, b: number, c: number,  ...rest: number[]) {\n    // ...\n}\nfunction g(s: string, a: number, b: number) {\n}\n// legal\nlet quad: [string, number, number, number, number] = [\"foo\", 1,2,3,4];\nlet triple: [string, number, number, number] = [\"foo\", 1,2,3];\nlet double: [string, number, number] = [\"foo\", 1,2];\nf(...quad); // and triple\nf(...double, 3);\nf(\"foo\", ...[1,2,3]);\nf(...quad, 1, ...[1,2,3]); // and triple\ng(...double);\n// illegal\nf(...double); // too short -- double doesn't match parameter 'c'\ng(...triple); // too many parameters\ng(...quad); // too many parameters\n```\n\nThe checker matches each member of the spread tuple argument with one parameter until \n1. A member's type does not match a parameter type, causing an error.\n2. The end of the parameter list is encountered, succeeding if there are no more tuple members.\n3. A rest parameter is encountered, succeeding if the remaining tuple members are typed as an array and that type matches the rest parameter's type.\n4. TODO: These rules don't account for trailing arguments that also match a rest parameter.\n# Notes\n\nThe tuple proposal has the problem that it types tuples as tuples in function applications only -- as arrays elsewhere. This is inconsistent, even if function application is arguably the most tuple-like of locations. And it's not clear whether either proposal will allow real uses of the spread operator that Javascript programmers are expecting.\n\nIf both proposals are implemented, function calls with spread array literals work in more cases if the literal is always typed as tuple, and provide more and better errors in the cases that do not type check:\n\n``` ts\nf(...[\"bar\",1,2,3,4,5]) // tuple gives no error; array gives error: bad type (number | string)[]\ng(...[\"bar\",1,2,3,4,5]) // tuple gives error: too long; array gives error bad type (number | string)[]\nfunction rest(a?: number, b?: number, ...rest:number[]);\nfunction fixed(a: number, b: number);\nrest(...[1,2,3,4,5]); // tuple gives no error; array gives no error\nfixed(...[1,2,3,4,5]); // tuple gives error: too long; array gives no error\n```\n\nSo spread array literals should always be interpreted as tuples.\n","author":{"url":"https://github.com/sandersn","@type":"Person","name":"sandersn"},"datePublished":"2015-10-16T21:18:23Z","url":"https://github.com/microsoft/TypeScript/issues/5296"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:8bcf4aae-c55f-158c-1c7c-8eb63fb5201b
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAC54:23CF06:20ED1E7:29F4FD2:6B016161
html-safe-nonce4e0aa5fe8f442e4a13c42cd7755e9a0a4063e6a62c4d5d944551c85ca2cecbf4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQzU0OjIzQ0YwNjoyMEVEMUU3OjI5RjRGRDI6NkIwMTYxNjEiLCJ2aXNpdG9yX2lkIjoiMjM0MDUwMTY3OTEwMDc0ODEyOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac6fb4687fa698263573fd714a241ae4445ec4297a03413cd8dbed41df736f81fb
hovercard-subject-tagissue:111913029
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/5296/issue_layout
twitter:imagehttps://opengraph.githubassets.com/e457689ba4b54604d09e69eecb58e8e99fac68c4d3618ab6838b4bb74ea807ba/microsoft/TypeScript/issues/5296
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/e457689ba4b54604d09e69eecb58e8e99fac68c4d3618ab6838b4bb74ea807ba/microsoft/TypeScript/issues/5296
og:image:altCurrently, Typescript does not support all uses of Ecmascript's spread operator. Specifically, in function calls, Typescript only supports spreading array arguments that match rest parameters. #413...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesandersn
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
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
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/5296#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F5296
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F5296
Sign uphttps://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/5296
Reloadhttps://github.com/microsoft/TypeScript/issues/5296
Reloadhttps://github.com/microsoft/TypeScript/issues/5296
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests312 (312)https://github.com/microsoft/TypeScript/pulls
Actionshttps://github.com/microsoft/TypeScript/actions
Projectshttps://github.com/microsoft/TypeScript/projects
Wikihttps://github.com/microsoft/TypeScript/wiki
Security and qualityhttps://github.com/microsoft/TypeScript/security
Insightshttps://github.com/microsoft/TypeScript/insights
https://github.com/microsoft/TypeScript
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/5296
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/5296
Proposal: Support spread operator for arrays and tuples in function callshttps://github.com/microsoft/TypeScript/issues/5296#top
https://github.com/sandersn
FixedA PR has been merged for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fixed%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
TypeScript 2.4https://github.com/microsoft/TypeScript/milestone/43
https://github.com/sandersn
Nathan Shively-Sanders (sandersn)https://github.com/sandersn
on Oct 16, 2015https://github.com/microsoft/TypeScript/issues/5296#issue-111913029
#4130https://github.com/microsoft/TypeScript/issues/4130
Nathan Shively-Sanders (sandersn)https://github.com/sandersn
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
on Oct 16, 2015https://github.com/microsoft/TypeScript/issues/5296#event-437981681
https://github.com/DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser)https://github.com/DanielRosenwasser
on Oct 18, 2015https://github.com/microsoft/TypeScript/issues/5296#issuecomment-149065090
#4759https://github.com/microsoft/TypeScript/issues/4759
https://github.com/sandersn
Nathan Shively-Sanders (sandersn)https://github.com/sandersn
on Oct 19, 2015https://github.com/microsoft/TypeScript/issues/5296#issuecomment-149336789
Anders Hejlsberg (@ahejlsberg)https://github.com/ahejlsberg
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
In DiscussionNot yet reached consensushttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22In%20Discussion%22
on Dec 9, 2015https://github.com/microsoft/TypeScript/issues/5296#event-487555418
https://github.com/niieani
Bazyli Brzóska (niieani)https://github.com/niieani
on Jun 28, 2016https://github.com/microsoft/TypeScript/issues/5296#issuecomment-229157074
https://github.com/DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser)https://github.com/DanielRosenwasser
on Jun 28, 2016https://github.com/microsoft/TypeScript/issues/5296#issuecomment-229157795
https://github.com/niieani
Bazyli Brzóska (niieani)https://github.com/niieani
on Jun 28, 2016https://github.com/microsoft/TypeScript/issues/5296#issuecomment-229158366
Daniel Rosenwasser (@DanielRosenwasser)https://github.com/DanielRosenwasser
https://github.com/Igorbek
Igor Oleinikov (Igorbek)https://github.com/Igorbek
on Sep 30, 2016https://github.com/microsoft/TypeScript/issues/5296#issuecomment-250661973
#6229https://github.com/microsoft/TypeScript/issues/6229
Add spread/rest higher-order types operator #10727https://github.com/microsoft/TypeScript/issues/10727
Nathan Shively-Sanders (@sandersn)https://github.com/sandersn
Proposal: Variadic Kinds -- Give specific types to variadic functions #5453https://github.com/microsoft/TypeScript/issues/5453
Proposal: strict and open-length tuple types #6229https://github.com/microsoft/TypeScript/issues/6229
https://github.com/josundt
josundthttps://github.com/josundt
on Jan 27, 2017https://github.com/microsoft/TypeScript/issues/5296#issuecomment-275701514
https://github.com/sandersn
Nathan Shively-Sanders (sandersn)https://github.com/sandersn
on Jan 27, 2017https://github.com/microsoft/TypeScript/issues/5296#issuecomment-275714830
Igor Oleinikov (@Igorbek)https://github.com/Igorbek
#5453https://github.com/microsoft/TypeScript/issues/5453
#6229https://github.com/microsoft/TypeScript/issues/6229
https://github.com/mhegazy
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
on May 10, 2017https://github.com/microsoft/TypeScript/issues/5296#issuecomment-300636325
#15747https://github.com/microsoft/TypeScript/issues/15747
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
CommittedThe team has roadmapped this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Committed%22
In DiscussionNot yet reached consensushttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22In%20Discussion%22
on May 10, 2017https://github.com/microsoft/TypeScript/issues/5296#event-1077333189
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
Nathan Shively-Sanders (sandersn)https://github.com/sandersn
on May 10, 2017https://github.com/microsoft/TypeScript/issues/5296#event-1077333215
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
TypeScript 2.4https://github.com/microsoft/TypeScript/milestone/43
on May 10, 2017https://github.com/microsoft/TypeScript/issues/5296#event-1077333223
Nathan Shively-Sanders (sandersn)https://github.com/sandersn
FixedA PR has been merged for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fixed%22
CommittedThe team has roadmapped this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Committed%22
on May 16, 2017https://github.com/microsoft/TypeScript/issues/5296#event-1084514378
Nathan Shively-Sanders (sandersn)https://github.com/sandersn
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#15849https://github.com/microsoft/TypeScript/pull/15849
on May 17, 2017https://github.com/microsoft/TypeScript/issues/5296#event-1086302277
Juan Valencia (calvellido)https://github.com/calvellido
on Sep 29, 2017https://github.com/microsoft/TypeScript/issues/5296#event-1271331340
Bump TypeScript version to 2.4.2https://github.com/frees-io/freestyle-opscenter-webclient/commit/d74f0eea1b5d4c87f904fb69e36aa78d2ee85084
d74f0eehttps://github.com/frees-io/freestyle-opscenter-webclient/commit/d74f0eea1b5d4c87f904fb69e36aa78d2ee85084
microsofthttps://github.com/microsoft
on Jun 19, 2018https://github.com/microsoft/TypeScript/issues/5296#event-1689620265
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/5296
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/5296
Nathan Shively-Sanders (sandersn)https://github.com/sandersn
FixedA PR has been merged for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fixed%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
TypeScript 2.4https://github.com/microsoft/TypeScript/milestone/43
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.