I try to write typescript functions in the style that is most close to functional. For simple functions I can write:
type A = (value: number) => string;
const a: A = value => value.toString();
But what can I do with generic types? How can I type in that simple way following function?
function a<T>(value: T): T {
return value;
}
If I try to simply add a generic type, it gives nothing:
type A = <T>(value: T) => T;
const a: A = value => value; // `value` implicitly has an `any` type
Is there any way to do it?