Closed as not planned
Description
π Search Terms
array never filter
π Version & Regression Information
- This changed between versions 5.4.5 and 5.5.2
β― Playground Link
π» Code
abstract class GenericClass {
protected constructor(public value: string) {}
}
class ConcreteClass extends GenericClass {
constructor(value: string) {
super(`Concrete: ${value}`);
}
}
const elements: GenericClass[] = [new ConcreteClass('a')];
const filteredElements = elements.filter((element) => element.constructor === ConcreteClass);
filteredElements[0].value.toString();
// ~~~~~
// Property 'value' does not exist on type 'never'.
π Actual behavior
The return type from the .filter()
expression is never[]
π Expected behavior
The return type from the .filter()
expression is GenericClass[]
Additional information about the issue
I searched through the open issues in the days since 5.5.2 were released but I could not find any which matched this case. Apologies if I missed anything. I've tried to reduce this down to the most minimal example that I can.