Skip to content

$PropertyType fails on extended class  #214

Description

@nrabinowitz

This is a:

  • Bug Report

Which concerns:

  • 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions