typescript-generator icon indicating copy to clipboard operation
typescript-generator copied to clipboard

Custom type mapping based on superclass

Open headphonejack opened this issue 4 years ago • 3 comments

I have a T extends AbstractClass<T> setup and wish for all T to become string in the TS models. Is this possible?

Many thanks

headphonejack avatar Oct 25 '19 14:10 headphonejack

That's not possible. There is customTypeMappings parameter but it only works with class names (and no inheritance). Where the generic variable T comes from? Is it class type parameter? Or method type parameter?

vojtechhabarta avatar Oct 28 '19 09:10 vojtechhabarta

Thanks for the reply @vojtechhabarta. The generic variable T I realised isn't so important to the problem I have as the existence of a supertype. So I could rephrase the problem as:

I have ? extends SuperClass and want all implementations of SuperClass to become string.

To that end I'm working on a PR as a proof of concept which I will submit shortly.

headphonejack avatar Oct 28 '19 16:10 headphonejack

Raised: https://github.com/vojtechhabarta/typescript-generator/pull/435

headphonejack avatar Oct 28 '19 17:10 headphonejack