This is a simpler example of what I'm trying to do:
export class Person{ id:Number; name:String; } export class PersonForm{
How can I make the compiler ignore this problem until Im uses nonexistent properties or how to declare a class so that I can assign in this way instead of the new Person () and then set only the properties I want.
Note. Sending an object with all the properties to the constructor is not the solution I expect. Also using the interface works because I can declare the fields optional, how can I do the same in the class?
Adding additional information:
The main goal of what I'm trying to achieve is:
Find the best way to declare a class (not an interface) so that I can initialize it with clean code in one line, setting only the parameters that I want to set. In Java, you must overload constructors or use the Builder pattern.
I could try the creator pattern, but I'm looking for a typescript way to do this, if any.
source share