'How can I specify U in a type expression involving Array<T>.prototype.map<U>?

In the following example

type Test = ReturnType<Array<string>['map']>

the type of Test is unknown[].

How can I parameterize the map function so that the type of Test becomes e.g. number[]?

I would expect something like

type Test = ReturnType<Array<string>['map']<number>>

but this is invalid syntax.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source