I am trying to create and use some Data Classes in NodeJs which i defined in Typescript and are at a point where i am wondering if there is a simpler way.
In javascript i was able to do
let myBuilding = new Building
Then i was able to just do
myBuilding.col1 = "Wall"
myBuilding.col2 = "None"
and so on
in typescript it doesn't like it if i don't declare everything at the point of declaration. Is there a way to initialize a class with blank values and then assign them later ? Also what happens when there is something that doesnt get a value assigned ? in javascript we dont get that item returned which is great when parsing from json to a class
Here is what a class of mine looks like
export class Exterior {
public exterior: string;
public fencing: string;
public security: string;
public sewer: string;
public lot: string;
public pool: string;
public patioPorch: string;
public spa: string;
constructor(exterior: string, fencing: string, security: string, sewer: string, lot: string, pool: string,
patioPorch: string, spa: string) {
this.exterior = exterior;
this.fencing = fencing;
this.security = security;
this.sewer = sewer;
this.lot = lot;
this.pool = pool;
this.patioPorch = patioPorch;
this.spa = spa;
}
}