Skip to content

Regression: 2.4.1 Generic type mismatch  #16985

Closed
@isuda

Description

@isuda

This is a simplified piece of code which demonstrates the problem. It compiles fine in 2.3.4 & 2.4.0, but produces a not assignable error in 2.4.1 and nightly.

TypeScript Version: 2.4.1 / nightly (2.5.0-dev.20170629)

Code

interface MyInterface {
  something: number;
}

class MyClass<T extends MyInterface> {
  doIt(data : Partial<T>) {}
}

class MySubClass extends MyClass<MyInterface> {}

function fn(arg: typeof MyClass) {};

fn(MySubClass);

Expected behavior:

No compile error.

Actual behavior:

test.ts(13,4): error TS2345: Argument of type 'typeof MySubClass' is not assignable to parameter of type 'typeof MyClass'.
  Type 'MySubClass' is not assignable to type 'MyClass<T>'.
    Types of property 'doIt' are incompatible.
      Type '(data: Partial<MyInterface>) => void' is not assignable to type '(data: Partial<T>) => void'.
        Types of parameters 'data' and 'data' are incompatible.
          Type 'Partial<T>' is not assignable to type 'Partial<MyInterface>'.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions