Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
maxzhou0 opened this issue Oct 1, 2023 · 2 comments Β· Fixed by #57116
Closed

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

maxzhou0 opened this issue Oct 1, 2023 · 2 comments Β· Fixed by #57116
Labels
Duplicate An existing issue was already created

Comments

@maxzhou0
Copy link

maxzhou0 commented Oct 1, 2023

πŸ”Ž 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

@whzx5byb
Copy link

whzx5byb commented Oct 1, 2023

Duplicate of #29919

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Oct 2, 2023
@typescript-bot
Copy link
Collaborator

This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants