Skip to content

Prefix <T> to access methods with generics : Klass[<T>"method"]Β #57297

Closed as not planned
@denis-migdal

Description

@denis-migdal

πŸ” Search Terms

generic methods

βœ… Viability Checklist

⭐ Suggestion

Use prefix <T> to access methods with generics:

class Klass {
    method<T>() {}
}

type Method = Klass[<number>"method"] // <number>() => void

Could also be extended for all <T>(...args: any[]) => any types :

type Fct = <T>() => void;
type FctT<U> = <U>Fct; // FctT<U> = <U>() => void;

I think there are no ambiguity with this syntax:

typeA<T>typeB  // syntax error
<T>typeA.typeB // = (<T>typeA).typeB
typeA.<T>typeB // = <T>(typeA.typeB)

πŸ“ƒ Motivating Example

Currently, there are no ways to access a method with generics from a class.

This would solve numerous issues :

πŸ’» Use Cases

  1. What do you want to use this for?

Access methods with generics

  1. What shortcomings exist with current approaches?

No current approaches.

  1. What workarounds are you using in the meantime?

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