I don't know if this is something that you're interested in accepting but figured I'd submit this and ask. This can be worked around as a consumer with some type casting 🙂
Currently, the class methods exported from classes ts-mountebank that use the builder patter (with<property>(...)), are typed as returning a hardcoded class type — this prevents consumers from extending the classes in an ergonomic way.
In the below example, you can see that the first image (current behaviour), after calling withName(...) on the instance of AutoPortImposter, typescript sees the return type as being the type of the parent class, where it's actually an instance of the subclass (or this). This PR modifies the return type to be this which allows extending classes defined in this library and using the builder pattern as expected.
I don't know if this is something that you're interested in accepting but figured I'd submit this and ask. This can be worked around as a consumer with some type casting 🙂
Currently, the class methods exported from classes
ts-mountebank
that use the builder patter (with<property>(...)
), are typed as returning a hardcoded class type — this prevents consumers from extending the classes in an ergonomic way.In the below example, you can see that the first image (current behaviour), after calling
withName(...)
on the instance ofAutoPortImposter
, typescript sees the return type as being the type of the parent class, where it's actually an instance of the subclass (orthis
). This PR modifies the return type to bethis
which allows extending classes defined in this library and using the builder pattern as expected.Before this PR:
After this PR: