1×
Become a member
to unlock all features
Autoplay

    Infer the Return Type of a Generic Function Type Parameter

    typescriptTypeScript
    ^3.0.0

    When working with conditionals types, within the “extends” expression, we can use the “infer” keyword to either get the type of the elements of an array, or even to get the return type of a function. We can use this to build a “FnReturnType” type, that will give us the return type of the function passed in as the generic parameter.