если вы предпочитаете обрабатывать это с помощью декоратора, вы можете создать свой собственный, например, такой:
function enumerable(value: boolean) {
return function (target: any, propertyKey: string) {
let descriptor = Object.getOwnPropertyDescriptor(target, propertyKey) || {};
if (descriptor.enumerable != value) {
descriptor.enumerable = value;
Object.defineProperty(target, propertyKey, descriptor)
}
};
}
, а затем пометить свойство как не перечисляемое, как этот
class MyClass {
@enumerable(false)
parent: MyClass;
}
другой вариантпереопределить toJSON поведение
MyClass {
...
public toJSON() {
const {parent, ...otherProps} = this;
return otherProps;
}