Skip to content

Request/How-to: Get return type of generic function #2201

@BribeFromTheHive

Description

@BribeFromTheHive

I have a function which accepts a generic function as its parameter. It does stuff with that function, then returns that function's return value(s) as its own. I would like for the returned properties to cascade from the generic function and propogate accordingly for type information.

In TypeScript, I would do:

const foo = <T extends Function>(func: T): ReturnType<T> => func(...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfeat/genericRelated to generic emulation feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions