Skip to content

TypeScript v4.5 regression: cannot use Parameters type on narrowed methods / functions#46855

@alecgibson

Description

@alecgibson

Bug Report

🔎 Search Terms

function, method, generic, parameters, does not satisfy constraint, 4.5

🕗 Version & Regression Information

  • This changed between versions 4.4.4 and 4.5.0

⏯ Playground Link

Playground link with relevant code

☝🏼 Switch the version to v4.4.4 and this compiles fine; v4.5.0-beta errors (as does v4.5.2, but the Playground doesn't offer this version)

💻 Code

typeMethods<T>={[KinkeyofT]: T[K]extendsFunction ? K : never;}[keyofT];classTest{foo='';bar(a: string,b: number): void{}}functiondoSomeProxying<T,MethodextendsMethods<T>,ArgsextendsParameters<T[Method]>,>(type: T,method: Method, ...args: Args): void{}doSomeProxying(newTest(),'bar','arg',123);

🙁 Actual behavior

Compiler errors in v4.5.0, even though it was fine in v4.4.4.

🙂 Expected behavior

Expect to be able to use the built-in Parameters<> type on properties I have narrowed down as functions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions