-
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
Mapping generic classes using customTypeMappings
parameter
#384
Comments
vojtechhabarta
added a commit
that referenced
this issue
Jul 6, 2019
Released in 2.16.538. |
This was referenced Jul 30, 2019
Closed
Hello @vojtechhabarta , I was using the following type mapping Is it possible to do this mapping in that version ? Is this a regression ? Thanks in advance for your answers. |
Fix released in version 2.17.558. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is possible to configure how some Java class is mapped to TypeScript. For example
org.joda.time.LocalDateTime
Java class can be mapped tostring
in TypeScript. For this purpose there iscustomTypeMappings
parameter which is list where each item specifies one mapping, for example like this:org.joda.time.LocalDateTime:string
.Mapping generic Java classes to TypeScript non-generic types
Originally when Java class was generic (for example
com.package.IdRepresentation<T>
) it could have been mapped to non-generic type likestring
usingcom.package.IdRepresentation:string
mapping.Mapping generic Java classes to TypeScript generic types
To support custom mapping of container types like lists and maps typescript-generator from version 2.10.466 mapped Java generic type parameters to TypeScript generic types. For example mapping Java class
ListWrapper<T>
to TypeScript typeListWrapper<T>
could have been configured usingcom.package.ListWrapper:ListWrapper
custom mapping. Unfortunately this feature broke previous possibility to map generic Java class to non-generic TypeScript type.Solution
To distinguish between these two cases new syntax is needed. But it is not clear which behavior should be preserved and which would use new syntax. To avoid ambiguity new syntax is required for all generic Java classes. This new syntax supports both mentioned cases and also allows new possibilities. Here are some examples:
To prevent character escaping in Maven
pom.xml
files it is also possible to use[]
characters instead of<>
. Here is Maven example:The text was updated successfully, but these errors were encountered: