Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Type constraint lost in conditional typeΒ #43578

Copy link
Copy link
@mjbvz

Description

@mjbvz
Issue body actions

Bug Report

πŸ”Ž Search Terms

  • extends
  • contain
  • constraint

πŸ•— Version & Regression Information

4.3.0-dev.20210407

This was working in the TS 4.3 beta

⏯ Playground Link

https://www.typescriptlang.org/play?#code/KYDwDg9gTgLgBDAnmYcCCATDAxAllAZxgAUBDKUgW2BmCgBUJsBXAOwGMZcJWCAeeuQDmNAHxwAvHADeAKDgK4AbQDScXKzgBrYIggAzOIKgiYAXQBcR4TVVm4oWqwwE4ACgB0X4QSulWiEpmAJSS4gBuELgY8opxAPzuXh4+VmQU1LSEAjYwdqKhEhFRMXFxVpHRsgC+ANyyQA

πŸ’» Code

export type AddFirstParameterToFunctions<Target> = {
    [K in keyof Target]: Target[K] extends (...args: any[]) => void
        ? (...args: Parameters<Target[K]>) => void
        : void
};

πŸ™ Actual behavior

Parameters<Target[K]> has the error:

Type 'Target[K]' does not satisfy the constraint '(...args: any) => any'.
  Type 'Target[keyof Target]' is not assignable to type '(...args: any) => any'.
    Type 'Target[string] | Target[number] | Target[symbol]' is not assignable to type '(...args: any) => any'.
      Type 'Target[string]' is not assignable to type '(...args: any) => any'

πŸ™‚ Expected behavior

This code previously compiled without errors in the TS 4.3-beta

Reactions are currently unavailable

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

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.