Skip to content

Remapped generic array type Can't pass to rest parametersΒ #55932

Description

@maxzhou0

πŸ”Ž Search Terms

rest parameters tuple array generic

πŸ•— Version & Regression Information

I tried some versions from 3.3.3 to 5.2.2 and Nightly version 。none of them fixed this problem.

⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.2.2&ssl=13&ssc=119&pln=1&pc=1#code/ATAuE8AcFNgJWpANgQwMbQDwBVjQB6jQB2AJgM7ADaAdHSseALoA0wAgmwEIB8wAvMADeAWABQIEFQDSwAJbFgAa2jgA9gDNg2JgC5tMpnkIkKHYAH5gXYPuyGA3OJABfJ2OdgosBMnTQABRQAJxQAW3IcYyIySlp6RlZOXn4ACjoaEIBzcl1fVAxMKmIAVzCAI2hgllKKqqSWXgBKfh4GcAcAek65SjUlTwgYeEQCwJDw8gBGTHY4OHYATWjTOIz2hpT0+mCcvNH-WfmllmSeFrbGLs6NFDkkaFJzYOhyUGBICbDoImDgMJKb2AlWAmmADHBwVC4C8MBog28Iz8GCCoQiACYogQYmZtpldrp2hd2qdGjw0utdrl8odUeEflVItgeKTmq12g5gN1bvdHs9Xu9PmiGX8AUCQWCISFobDoPCPAqQEMfNAwihIDBSFiTLFqOtEnx+KIJJIZPJFCp1FodLp7NImJ4XAjhgBlORhZDQADCKHIWFw2NWeoSzENwDx2WpqvVmpw53ZV25dweT3YwBeQKF9N+-0B7wlWilUJQMOVNCAA

πŸ’» Code

  type Replace<T extends [...any], A, B> = {
    [K in keyof T]: T[K] extends A ? B : T[K];
  };

  type ReplaceParams<T extends [...any],A,B>=(...args:Replace<[number,number],A,B>)=>any;//is ok
  type ReplaceParams1<ARRAY extends [...any],A,B>=(...args:Replace<ARRAY,A,B>)=>any;//failed A rest parameter must be of an array type.
  type ReplaceParams2<T extends (...arg:any)=>any,A,B>=(...args:Replace<Parameters<T>,A,B>)=>any; //failed A rest parameter must be of an array type.


  type Remapped<T extends [...any]> ={
    [K in keyof T]:T[K]
  }
  type SimpleCase<T extends [...any]> = (...args:Remapped<T>)=>any;//failed A rest parameter must be of an array type.

πŸ™ Actual behavior

this was happend at latest version 5.2.2

and in the next version still no fixed

πŸ™‚ Expected behavior

quite sure tuple or array type can be passed to function rest pamaters. but remapped cant.this make replace certain type in parameters inpossible.

Additional information about the issue

No response

Activity

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

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions