Here is the type definition that I am working with:
type Inner<Type> = Type extends Wrapper<infer U>[] ? U[] : never;
Additionally, I have a function with the following signature:
function myFunc<From extends Wrapper[], To>(
values: From,
transform: (v: Inner<From>) => To
)
When I provide a callback as the transform
argument, the argument list inferred for that callback becomes an array of union types instead of preserving the original order.
For example, if the values
array is
[Wrapper<number>, Wrapper<string>]
, then the arguments inferred for transform
would be (number|string)[]
(without maintaining the order), when I intended it to be [number, string]
.
Is there any way to retain the order in this scenario?
*Edit
For the purpose of this discussion, you can assume that Wrapper
is defined as type Wrapper<T> = {x:T}