This project is read-only.

inheritance from a more specified generic type

Topics: Language Specification
Jul 9, 2013 at 10:07 AM

I'd like to have two interfaces, one with 3 generic parameters, and a second with only two, inheriting from the first where the third template parameter is any
interface A<I, J> extends A<I, J, any>{

interface A<I, J, K> {
the typescript compiler throws an error saying that "Generic type A<I, J, K> is recursively referenced as a base type of itself.
The two types are however different.

Could you explain me why this behavior is forbidden?

Jul 9, 2013 at 4:47 PM
I believe that overloading on the number of type parameters is currently something that's disallowed based on a slightly older version of the spec, where we allowed you to leave off the type parameters when referring to the type (like A above). At first glance, I can't think of a reason not to allow this in the future, though there might be something subtle here I'm not seeing.