Typescript: прекомпилировать и изменить свойства - PullRequest
0 голосов
/ 02 марта 2020

Я часто сталкиваюсь со следующим блоком кода, иногда со многими полями в классе:

// initialize the private, editable properties so
// they can be manipulated within the class
private readonly aSubject = new SubjectVariant<A>()
private readonly bSubject = new SubjectVariant<B>()
private readonly cSubject = new SubjectVariant<C>()

// make the the streams publicly viewable, but not 
// editable, so they don't get manipulated by accident
public readonly a$ = aSubject.asObservable()
public readonly b$ = bSubject.asObservable()
public readonly c$ = cSubject.asObservable()

Есть ли способ DRY это с @decorator, при этом сохраняя предложения типа?

...