-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Open
Labels
In DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
TypeScript Version: 4.1.2 & Nightly 4.2
Search Terms: concat, spread
Code
type First = [number, string];
type Second = [string, string];
type Result = [...First, ...Second];
function concat (first: First, second: Second): Result {
return first.concat(second); // error
}
function spread (first: First, second: Second): Result {
return [...first, ...second]; // ok
}
Expected behavior: concat
function works similarly to spread
function without an error.
Actual behavior: Type '(string | number)[]' is not assignable to type '[number, string, string, string]'. Target requires 4 element(s) but source may have fewer.(2322)
Playground Link:
playground
Related Issues: #36554
Metadata
Metadata
Assignees
Labels
In DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript