Skip to content

How about generic parameters in the "Function" type? #26114

Closed
@samchon

Description

@samchon

Since v3.0 update, defining generic rest parameters is possible. The, how about adding generic parameters in the Function type and related features?

By the implementation, specifying those methods' types are possible (who've handled only any type):

  • Function.apply clearly.
  • Function.bind maybe?
interface Function<Ret = any, Params extends any[] = any>
{
    // It's possible to specifying types of return and parameters.
    apply(thisArg: any, args: Params): Ret;

    // Well, I don't know the solution... but it seems possible maybe...
    bind<T>(thisArg: any, elem: T): Function<Ret, Pop<Params, T>>;
    bind<Pops extend any[]>(thisArg: any, ...args: Pops): Function<Ret, Remainder<Params, Pops>>;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions