将 angular 升级到 11 后的不可变数组

Immutable arrays after upgrading angular to 11

我刚刚将 Angular 从 6 升级到 11,并将 typescript 升级到 4.1.5。 我在更改数组中任何对象的属性时遇到问题。结果出现错误

core.js:6150 ERROR TypeError: Cannot assign to read only property 'active' of object '[object Object]'

我要更改的对象是:

  export interface Agreement {
    active: boolean;
    ...
}

另外,当我尝试向任何列表中添加内容时,出现此错误:

ERROR TypeError: Cannot add property 4, object is not extensible
at Array.push (<anonymous>)

我是否缺少任何全局配置 属性?

我只是像这样创建了给定字段的副本:

field = JSON.parse(JSON.stringify(field))