w3tecch / class-mapper Goto Github PK
View Code? Open in Web Editor NEWA easy to use way to map any ugly backend structures into clean TypeScript/ES6 models
License: MIT License
A easy to use way to map any ugly backend structures into clean TypeScript/ES6 models
License: MIT License
Is your feature request related to a problem? Please describe.
I am unable to use the PropertyType
decorator for property which may be null
or undefined
.
Describe the solution you'd like
The solution might be as simple as adding the enabled
option behaving exactly the same as it does in the MapFromSource
decorator but independently of each other
Additional context
Simple example of the problem:
class Foo {
@MapFromSource(obj => obj.anything)
public something!: string;
}
class Bar {
@PropertyType(Foo)
@MapFromSource(obj => obj.maybeFoo)
public foo!: Foo | null;
}
This one works as expected:
mapClasses({
maybeFoo: {
anything: 'whatever'
}
}, Bar);
But this one:
mapClasses({
maybeFoo: null
}, Bar);
Throws an error, however i would expect the result to be this:
{
foo: null
}
Describe the bug
I tried to use this library for serialization responsed dto. so I wanted to transform typeorm entity to response dto class.
when target class was nested class, it has an array property. I tried to use PropertyType
decorator . but I got an error.
May I know how? plz answer me . thanks
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional Information (please complete the following information):
Additional context
Add any other context about the problem here.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.