Our great sponsors
-
Then, with the way you're typing the Axios response I would go with a simple IUser interface if the endpoint and your classes share the same shape, but reduce the number of types you have since this is Ts and interfaces aren't enforced the way they would be in C#. Instead you can use a library like io-ts to validate the schema.
-
class-transformer
Decorator-based transformation, serialization, and deserialization between objects and classes.
The most straightforward answer is class-transformer. It's a library that has already seen widespread use in the Typescript community and is featured in the NestJS framework with a full array of features that meet your requirements.
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
-
On top of that, you want to keep in mind why some other commenters have said not to use classes. If you aren't getting any benefit from them, such as methods or getters and setters, it's more common to use objects in Ts but there's nothing inherently wrong with using classes as you can then combine them with additional libraries such as class-validator to bake a ton of functionality into your apps.