Прежде всего, вы неправильно набрали: ?
не означает, что значение может быть null
, это означает, что оно может быть undefined
.
На ваш вопрос подумайте о JavaScript вывод, вы на самом деле хотите, чтобы все поля были установлены на null
, поэтому нет никакого способа присвоить его. Тем не менее, вы можете сократить это назначение, хотя я не уверен, что оно будет меньше набирать:
export class PropertySitusAddress {
primaryPropertyMailingAddressId?: number | null;
propertyId?: number | null;
propertySitusAddressId?: number | null;
addressFormatId?: number | null;
apn?: string | null;
owner?: string | null;
situsAddress?: string | null;
primaryMailingAddress?: string | null;
streetNumber?: string | null;
situsFromNumber?: string | null;
situsThroughNumber?: string | null;
fractional?: string | null;
predirectional?: string | null;
constructor() {
this.primaryPropertyMailingAddressId =
this.propertyId =
this.propertySitusAddressId =
this.addressFormatId =
this.apn =
this.owner =
this.situsAddress =
this.primaryMailingAddress =
this.streetNumber =
this.situsFromNumber =
this.situsThroughNumber =
this.fractional =
this.predirectional = null;
}
}
Полагаю, лучшее предложение - использовать редактор с функцией для нескольких курсоров (например, vscode). )