Typescript check type against enum
You could use a custom mapped type:
type VehicleConfig= {
[P in keyof VehicleProperties]: {
type: P,
properties: VehicleProperties[P]
}
}[keyof VehicleProperties]
const vehicle: VehicleConfig = {
type: Vehicle.Car,
properties: {
amountOfWheels: 4
}
}
Playground Link