对象文字只能指定已知属性,并且'registerFormState'在'stateManagementProps'类型中不存在

时间:2019-09-27 03:44:48

标签: javascript reactjs typescript react-redux react-hooks

我正在尝试将对象用作我的应用状态的入口点,但似乎TS阻止了我执行doig操作,因此标题出现throwinand错误。

这是对象:

const registerFormBasicState = {
  location: {
    locationExtraDetails: {
      regon: 0,
      name: "",
      nip: "",
      krs: "",
      address: "",
      postalCode: "",
      postalCity: "",
      city: "",
      district: "",
      phoneNumber: "",
      internalNumber: "",
      homePage: "",
      companyEmail: "",
      companyProfile: [{id:"", value:""}],
      agreeToSellingEmails: false,
      agreeToSellingPhones: false,
      agreeToMarketingEmails: false,
      agreeToMarketingPhones: false,
      agreeToSharingData: false
    }
  }
};

这是我为保存数据的组件创建的接口:

export interface data {
  location: {
      fullName: string;
      locationExtraDetails: {
      regon: number;
      name: string;
      nip: string;
      krs: string;
      address: string;
      postalCode: string;
      postalCity: string;
      city: string;
      district: string;
      phoneNumber: string;
      internalNumber: string;
      homePage: string;
      companyEmail: string;
      options: any;
      agreeToSellingEmails: boolean;
      agreeToSellingPhones: boolean;
      agreeToMarketingEmails: boolean;
      agreeToMarketingPhones: boolean;
      agreeToSharingData: boolean;
    }
  }
};

完整错误:

  Object literal may only specify known properties, and 'registerFormState' does not exist in type 'stateManagementProps'.ts(2322)```

0 个答案:

没有答案