Skip to content

Poor parameter help for ...args when inferring from multiple argument lists #26132

Description

TypeScript Version: 3.1.0-dev.20180730

Code

type Rec = {
  foo: (a: string, b: number) => void,
  bar: (b: boolean, c: RegExp) => void,
}

type Parameters<T> = T extends (...args: infer U) => any ? U : never;

declare var fn: <K extends keyof Rec>(e: K, ...args: Parameters<Rec[K]>) => void;
fn('foo', /* get parameter help here */);

Expected behavior:
Since I've provided 'foo', the only acceptable parameters to follow are a: string, b: number.

Actual behavior:
Parameter help shows me the union of all possible types for ...args including ones that will give me a type error if I use them.

Activity

  1. ghost added
    FixedA PR has been merged for this issue
    on Aug 23, 2018
  2. ghost closed this as completedon Sep 17, 2018
  3. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions