DEV Community

Discussion on: Typescript Interface vs Class With Practical Examples

Collapse
 
bentaly profile image
Ben Taliadoros

There is no need to add the properties on a ts class if they match the constructor. Simply add an access modifier (public for example):
"constructor(public xyz:string) {}"
And it will be automatically added as a property of the class and assigned the value.