Skip to content

Manipulated tuple type not allowed to be spread/not recognized as iterableΒ #53089

Closed
@majellin24

Description

@majellin24

Bug Report

πŸ”Ž Search Terms

tuple type spread, symbol iterator spread

πŸ•— Version & Regression Information

  • This changed between versions 4.6.4 and 4.7.4

⏯ Playground Link

Playground link

πŸ’» Code

type Mapped<T extends any[]> = { [ P in keyof T ] : T[P] }

function fn<T extends (...args: any[]) => any>(cb: T, ...rest: Mapped<Parameters<T>>): ReturnType<T> {
  return cb(...rest);
  //           ^?
}

πŸ™ Actual behavior

The code failed to compile with the error


Type 'Mapped<Parameters>' must have a 'Symbol.iterator' method that returns an iterator.


πŸ™‚ Expected behavior

Prior to 4.7.4 this compiled. I included the types "paramsOfTest" and "paramsOfNone" to demonstrate that the resulting types do evaluate to tuples, even without any parameters. It seems to me that the type should always evaluate to an iterable tuple since the "Parameters" type should evaluate to a tuple and the types ReplaceIndexWithUndefined and FilterUndefined should also evaluate to iterable types due to their type constraints.

Edited to use the simpler repro from comments to simplify.

Given that this was working previously and I was not able to find more information I assumed this was a bug but I apologize if I have missed something.

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