Skip to content

Assignability check not enough for class that is mutually recursive with an interface? #39947

Closed
@uhyo

Description

@uhyo

TypeScript Version: 3.9.2, 4.0.1-rc

Search Terms: class no type error interface

Code

Unbelievably this is the minimal reproduction I was able to make.

interface I<Dummy, V> {
  c: C<Dummy, V>;
}

class C<Dummy, V> {
  declare sub: I<Dummy, V>;

  declare covariance: V;
}

// should be a type error, but none emitted
const c1: C<unknown, string> = new C<unknown, number>();

Expected behavior:

new C<unknown, number>() should not be assignable to C<unknown, string> due to existence of the covariance property.
TSC should emit an error like Type 'C<unknown, number>' is not assignable to type 'C<unknown, string>'.

Actual behavior:

No error.

Playground Link: link

Related Issues: none found (sorry, hard to explain the exact problem so no good search terms came up)

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions