Skip to content

Deriving from object and intersection types problem #13732

Closed
@tamayika

Description

@tamayika

TypeScript Version: nightly (2.2.0-dev.20170128)

Code

interface Person{
  name: string;
}

interface A<T> {

}

type _A<T> = A<T> & T;

interface B<T> extends _A<T> { }

type TypedPerson = B<Person>;

Expected behavior:
no error
Actual behavior:
line interface B<T> extends _A<T> { } is error // TS2312: An interface may only extend a class or another interface.

Now, we can deriving from object and intersection types by #13604.
But this is only for _A<T> is statically composed of object or intersection types.
I think we can solve this problem if we can delay type evaluation until actual type resolution at the line type TypedPerson = B<Person>;
or, we need generics type restriction like below?

interface B<T is interface> extends _A<T> { }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions