Skip to content
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

Map primitive types to a custom type (e.g.: long to BigInt) #650

Closed
nanella opened this issue Mar 11, 2021 · 5 comments
Closed

Map primitive types to a custom type (e.g.: long to BigInt) #650

nanella opened this issue Mar 11, 2021 · 5 comments

Comments

@nanella
Copy link

nanella commented Mar 11, 2021

Hi,
thanks for your awesome library. I've found only one case where I can't find a solution:

The Java API returns a long, which gets represented as a number in typescript per default. Sadly, a number is not enough in this case and I would like to map the type to BigInt. This works seamlessly with the class Long, but I can't get it to work with the primitive type.

Is there any way to configure this? If not, could this be implemented in some way?

@vojtechhabarta
Copy link
Owner

Hi, you are right, mapping Java long to TypeScript BigInt is not currently possible but it should be possible.
Just for curiosity: how are you parsing numbers in JSON into BigInt?

@nanella
Copy link
Author

nanella commented Mar 16, 2021

Since I'm using axios, I'm planning on using transformResponse in combination with a BigInt JSON library to parse the json longs to BigInt. (For a simpler usecase, I could also convert the long to string in the same way if I would be able to map the long to string in the generator configuration.)

@ghost
Copy link

ghost commented Mar 31, 2021

I have the same problem, I did fix it with converting to string, but I am interested do you plan on fixing this soon?

@vojtechhabarta
Copy link
Owner

There was already support for custom mapping of arrays of primitive types (done in #636) so I just made it work also for this case.

@vojtechhabarta
Copy link
Owner

Released in v2.32.889.

mohasarc pushed a commit to mohasarc/typescript-generator that referenced this issue Jun 24, 2021
mohasarc pushed a commit to mohasarc/typescript-generator that referenced this issue Jun 24, 2021
mohasarc pushed a commit to mohasarc/typescript-generator that referenced this issue Jun 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants