-
Notifications
You must be signed in to change notification settings - Fork 238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parameterized type propagates type parameters to customTypeMapping #358
Comments
Thanks for precise description of the problem. I think it is not possible to detect if target type (in this case I see some possibilities how to solve this issue but non of them is ideal.
What do you think? Do you know what I mean by these solutions? |
Thank you for your quick response. Yes I do know what you mean. I did briefly examine the possibility of creating a PR for something similar to the first of the possibilities that you list, and ultimately decided not to since I did recognize that it would affect the customTypeMapping syntax in ways that you would probably want to have a say in anyways. Both of your suggestions are possible to employ in our project, that beeing said though, I would prefer the first one since we do have a number of types that are being affected. The second solution would leave us with quite a number of interfaces that are defined using alias types for string and making code somewhat harder to read and understand. |
Currently Workaround using type alias is little bit complicated but I think it's still feasible. Here is example how it can be done: Create file export type Id<T> = string; Import <importDeclarations>
<import>import { Id } from './id'</import>
</importDeclarations> And change mappings: <customTypeMappings>
<mapping>IdRepresentation1:Id</mapping>
<mapping>IdRepresentation2:Id</mapping>
</customTypeMappings> There is just one If you also have number IDs you could have two aliases |
In version 2.15 I added Maven example: <configuration>
<customTypeMappings>
<mapping>IdRepresentation1:Id</mapping>
<mapping>IdRepresentation2:Id</mapping>
</customTypeMappings>
<customTypeAliases>
<alias>Id<T>:string</alias>
</customTypeAliases>
</configuration> Please note that Is this acceptable solution for you? |
I am having same problem. It is working perfect in 2.0.400 version. But a side effect got introduced into the |
I'm a colleague of @bjorsa working in the same project as him, I just updated typescript-generator to 2.16.538 which seems to work fine. Thank you! |
Given the following hierarchy of classes
And the following customTypeMapping
The generator will yield the following result.
(Sorry for the pseudocode, I will provide a real example if needed).
Which of course won't compile as typescript.
This problem was introduced with version 2.10.466 as part of the rewrite concerning the handling of type parameters for customTypeMappings.
The text was updated successfully, but these errors were encountered: