クラスのコンストラクタの引数としてオブジェクトを渡したいとします。オプションオブジェクトの一部のキーはオプションです。options引数のオプションパラメータのデフォルト値
typescriptで以下のことを行うのは、より寛容な方法がありますか?ありがとう
class Car {
color: number;
numberOfWheels: number;
constructor (options: {color: number, numberOfWheels?: number}) {
options.numberOfWheels |= 4;
this.color = options.color;
this.numberOfWheels = options.numberOfWheels;
}
}