The specific name of the inner generic is not clearly defined, but it represents the type of the function to which you pass the callback fn
. Let's gain a better understanding by actually implementing this type:
// Updated as `<R>(fn: (s: number) => R)`
const exampleFunction: F<number> = callbackFn => callbackFn(1);
// num is a number
const result1 = exampleFunction<string>(num => num.toString());
// error due to `num` being a number without `length`
const result2 = exampleFunction<string>(num => num.length);
// returning a boolean instead of a string results in an error
const result3 = exampleFunction<string>(num => !!num);