IssueRaiser

Enable type parameter lower-bound syntax

<!-- BUGS: Please use this template. --> <!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript --> <!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md --> **TypeScript Version:** 2.1.1 **Code** ```ts 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: ```ts class Animal {} class Cat extends Animal {} class Kitten extends Cat{} function foo<A extends Animal>(a: A) { /* */ } ``` People in issue [#13337](https://github.com/Microsoft/TypeScript/issues/13337) have suggested to use ```ts 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).

Posted by jyuhuan on Mar 7, 2017, 8:12 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.4,500 issues0 comments

support (Software)

Enable type parameter lower-bound syntax

jyuhuanMar 7, 2017, 8:12 PM

<!-- BUGS: Please use this template. --> <!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript --> <!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md --> **TypeScript Version:** 2.1.1 **Code** ```ts 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: ```ts class Animal {} class Cat extends Animal {} class Kitten extends Cat{} function foo<A extends Animal>(a: A) { /* */ } ``` People in issue [#13337](https://github.com/Microsoft/TypeScript/issues/13337) have suggested to use ```ts 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).

Comments (0)

No comments yet. Start the discussion.

Comment on this issue