How could I deal with optional parameters in Typescript?
I have the following model:
export class PowerPlant {
id: number;
orgName: string;
minPower: number;
maxPower: number;
powerPlantType: string;
rampRateInSeconds: number;
rampPowerInKw: number;
}
In this model, the last two fields namely the rampRateInSeconds and rampPowerInKw are going to be optional values and will be there depending on the powerPlantType string. I want to be able to instantiate this in the constructor and in the constructor, I will check the powerPlantType string and if it is of a certain type, I would like to set these 2 additional fields.
Coming from a functional programming background, I would have these 2 types as optional and pattern match on the powerPlantType String and set the 2 values accordingly. How could I achieve the same effect here in Typescript?