-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
Bug Report
π Search Terms
merged parameters rest union never
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about
union
β― Playground Link
Playground link with relevant code
π» Code
type RestParams = [y: string] | [y: number];
type Signature = (x: string, ...rest: RestParams) => void;
type MergedParams = Parameters<Signature>; // never
π Actual behavior
MergedParams
is of type never
.
π Expected behavior
MergedParams
is of type [x: string, y: string] | [x: string, y: number]
I realise this can sort of be done by using [y: string | number]
as type for RestParams
. However, I'm using unions in parameters like this in order to overload the signatures of functions in jsdoc as shown here: #25590 (comment)
If I use a union like that it will show up as union in VSCode, instead of using the multiple signatures UI.
Here's an example of this: Playground link.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue