Description
I have a strange one that I can't figure out. It works fine with Typescript before 2.7.* and it has to be some kind of related to the abstract method with generics. When I remove that abstract method, it works. It's also working if I replace the abstract generic with any, from public abstract evaluate(items: Array<TEntity>): Array<TEntity>
to public abstract evaluate(items: Array<any>): Array<any>
I have no idea what to name this issue, sorry for the title.
TypeScript Version: 2.7.1
Code
enum OperatorType {
Take = 1 << 1,
Skip = 1 << 2,
}
class Operations<TEntity> {
public first<T extends Operator<TEntity>>(operator: { new (...args: any[]): T }): T {
return null;
}
}
abstract class Operator<TEntity> {
constructor(public type: OperatorType) {
}
public abstract evaluate(items: Array<TEntity>): Array<TEntity>
}
class SkipOperator<TEntity> extends Operator<TEntity> {
constructor(public count: number) {
super(OperatorType.Skip);
}
public evaluate(items: Array<TEntity>): Array<TEntity> {
return null;
}
}
interface ICar {
id: number
}
let count_failing = new Operations<ICar>().first(SkipOperator).count;
let count_working = new Operations<{}>().first(SkipOperator).count;
Expected behavior:
compile without any error
Actual behavior:
throws an error; error TS2339: Property 'count' does not exist on type 'Operator<ICar>'.
even when the signature of method first
indicates it should return SkipOperator instead of Operator.
Related Issues: