Reputation: 9874
How do I write flowtype for the following code?
The function argument is an array of generic type.
const fn = (array) => Promise.resolve(array[0]);
Upvotes: 22
Views: 8761
Reputation: 1446
const fn = <T>(array: Array<T>): Promise<T> => Promise.resolve(array[0]);
Relevant documentation: https://flow.org/en/docs/types/generics/
Upvotes: 42