Skip to content

Trying to get the type of a generic method of a class results in a parse errorΒ #53410

Closed
@mckravchyk

Description

@mckravchyk

Bug Report

πŸ”Ž Search Terms

get type of a generic class method parse error

πŸ•— Version & Regression Information

This is the behavior in every version I tried, and I reviewed the FAQ for entries about it.

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

class Foo {
    public bar<T extends string>(arg: T): T {

    }
}

type fType = Foo['bar']<'test'> // ; expected

πŸ™ Actual behavior

I'm not able to get the type of a generic method in a class. It results in a parse error.

πŸ™‚ Expected behavior

Getting type of a generic method of a class should be possible.

Additional information

I need this to get the return type of a generic function from within to cast the return result (a workaround to to the bug with generic conditionals not resolving in certain cases).

It's not possible to just create a separate type to hold a reference to the method type because that type is not going to be a generic, and if you try to make a generic type out of it, it will result in the same problem. I'm not aware of any workarounds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions