How to get the child type from a function defined on the parent type?


I have a parametric Parent and several children types:

extendable entity type Parent<P>
entity type ChildA extends Parent<A>
entity type ChildB extends Parent<B>

On the type Parent, I defined a function foo that is common to all the children but in which I want to create an instance of the child, e.g.:

function foo() {

// when I call
// I expect to have a new instance of ChildA in my database

How do I access to the “current” child type on from the implementation of a function on the type Parent?


I think:

function foo() {

should work if the function is a member method.


if a static method