The engine type (combustion, electric, or undefined for generic)
Represents dynamic properties that vary during a journey:
Unlike the vehicle model (static properties), state changes as the vehicle travels and consumes fuel/energy.
// Generic vehicle with heading
const genericState: VehicleState = {
heading: 90 // Facing east
};
// Combustion vehicle with fuel
const combustionState: VehicleState<'combustion'> = {
currentFuelInLiters: 45,
heading: 180
};
// Electric vehicle with battery percentage
const evState: VehicleState<'electric'> = {
currentChargePCT: 75,
heading: 0
};
// Electric vehicle with absolute energy
const evKwhState: VehicleState<'electric'> = {
currentChargeInkWh: 60,
heading: 45
};
Vehicle state - current conditions that change during travel.