Skip to content

Enable type parameter lower-bound syntax #14520

Description

@jyuhuan

TypeScript Version: 2.1.1

Code

classAnimal{}classCatextendsAnimal{}classKittenextendsCat{}functionfoo<AsuperKitten>(a: A){/* */}

Expected behavior:
The type parameter A has the type Kitten as lower-bound.

Actual behavior:
Compilation failure. The syntax is unsupported.

Discussion:
The upper-bound counterpart of the failed code works fine:

classAnimal{}classCatextendsAnimal{}classKittenextendsCat{}functionfoo<AextendsAnimal>(a: A){/* */}

People in issue #13337 have suggested to use

functionfoo<XextendsY,Y>(y: Y){/* */}

to lower-bound Y with X. But this does not cover the case where X is an actual type (instead of a type parameter).

Metadata

Metadata

Assignees

No one assigned

    Labels

    In DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions