in C# you would write
T RandomFrom< T >( List< T > list ) {
return list[ ( int ) Math.Floor( new Random().Next() * list.Count ) ];
}
How should I do the same when documenting a JS function? I tried:
/**
* @type {*} T
* @param {T[]} list
* @returns {T}
*/
function randomFrom ( list ) {
return list[ Math.floor( Math.random() * list.length ) ];
}
But VS Code tells me randomFrom(list: any[]): any and I'd like it to be something like randomFrom(list: <T>[]): <T>. How do I achieve that? Putting the T inside <> makes it an arrow function.