
One thing that is great in C# is the ability to initialise values on create like so: –
MyObject test = new MyObject { Name="Test", Description="This is a description" };
With the release of TypeScript 2.1 you can now do something similar: –
export class MyObject{ public Name: string; public Description: string; public constructor( fields?: { Name?: string, Description?: string }) { if (fields) Object.assign(this, fields); } }
Then you can use is like so:-
new MyObject({ Name:"Test", Description="This is a description" });
Just make sure that in your package.json that devDependencies has typescript 2.1 or higher.