flow-runtime
flow-runtime copied to clipboard
$PropertyType fails on extended class
This is a:
- [x] Bug Report
Which concerns:
- [x] flow-runtime
What is the current behaviour?
I am trying to use $PropertyType
to check the property of an extended class. The following code illustrates the issue:
class AbstractClass {
prop: any;
};
type ClassProp<C: AbstractClass> = $PropertyType<C, 'prop'>;
class ConcreteClass extends AbstractClass {
prop: number;
}
const i = 12;
(i: ClassProp<ConcreteClass>);
Running this example in the Try Flow-Runtime interface throws the following error: Can only intersect object types
.
What is the expected behaviour?
Parity with Flow: The same code runs without errors in Flow
It also correctly errors on failures against the extended type.
Which package versions are you using?
Tried in the current Try Flow-Runtime interface, assuming this is v0.17.0