TS2339: 属性 'assign' 类型不存在

TS2339: Property 'assign' does not exist on type

我有一个包含静态数据的文件 QRCategories,我想将数据作为可观察对象发送。

发送数据的服务是

public qrCodeCategoriesList(): Observable<QRCategoryListResponse> {
    return of (QRCategories);
  }

它在组件中用作:

ngOnInit() {
   this.qrCategoryService.qrCodeCategoriesList().subscribe(
     res => {
       this.qrCategories = res;
     }, error => {
       console.log(error);
     }
   );
  }

工作正常但给出错误 属性 'assign' does not exist on type in the below line at different component :

  const formData: RegisterData = this.registerForm.value;
  const password2 =   {password2: formData.password1};
  const data = Object.assign({}, formData, password2);

qr-category.ts

import {QRCategoryListResponse} from '../models/qr/qr-category.model';

export const QRCategories: QRCategoryListResponse = {
  count: 10,
  next: null,
  previous: null,
  results: [
    {
      id: 1,
      name: 'Website URL',
    },
    {
      id: 2,
      name: 'Google Maps',
    },
    {
      id: 3,
      name: 'PDF',
    },
    {
      id: 4,
      name: 'Image',
    }
   ]};

在这里,尝试使用以下内容:

const data=(<any>Object).assign(formData, password2)

data={...formData,...password2};

确保这将通过引用复制嵌套对象,因此使用深度复制代替像 Lodash 这样的库,或者:

JSON.parse(JSON.stringify(someData));