microsoft / microsoft/TypeScript
Enable type parameter lower-bound syntax
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 2.1.1
Code
class Animal {}
class Cat extends Animal {}
class Kitten extends Cat{}
function foo<A super Kitten>(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:
class Animal {}
class Cat extends Animal {}
class Kitten extends Cat{}
function foo<A extends Animal>(a: A) { /* */ }
People in issue #13337 have suggested to use
function foo <X extends Y, 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).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the proposed A super Kitten syntax and the discussion in issue #13337, since no implementation files or tests are identified here. Determine the language and type-checking changes required, then add coverage showing that lower-bound type parameters compile and behave as described.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100