How to init a new class in TS
in such a way (example in C#
to show what I want):
// ... some code before
return new MyClass { Field
I suggest an approach that does not require Typescript 2.1:
class Person {
public name: string;
public address?: string;
public age: number;
public constructor(init:Person) {
Object.assign(this, init);
}
public someFunc() {
// todo
}
}
let person = new Person({ age:20, name:"John" });
person.someFunc();
key points:
Partial
not required