-2

I have an interface like so:

enter image description here

And a component like so:

enter image description here

But I am getting this error:

enter image description here

How can I destructure my values so that Typescript will be happy?

Phillip Berger
  • 2,317
  • 1
  • 11
  • 30
  • 3
    Please post actual code, not pictures of code. – djs Jan 04 '19 at 16:34
  • What do you mean *"destructure my values"* - are you expecting only to assign the first element, for example? Also `AccountList` seems like an odd name for something that isn't a list. – jonrsharpe Jan 04 '19 at 16:36
  • Questions on Stack Overflow cannot depend on screenshots of code. Your code has to go in your question as text. – user229044 Jan 04 '19 at 16:51

2 Answers2

3

In your local declarations, can you try :

@Input() accounts: Accounts;
myAccountsList: Array<AccountList>;
authorizedAccountsList: Array<AccountList>;
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
dun32
  • 708
  • 6
  • 9
0

I think is because you are declaring the variables of myAccountsList and authorizedAccountsList as AccountList type, but in the interface you defined as Array<AccountList>. Depending of which of the types is the correct one, you need to change:

If the type is AccountList, change on the interface:

export interface Accounts {
    authorizedAccountsList: AccountList;
    myAccountsList: AccountList;
}

If the type is Array<AccountList>, change on the declaration of the variables:

@Input() accounts: Accounts;
myAccountsList: Array<AccountList>;
authorizedAccountsList: Array<AccountList>;
Milo
  • 3,365
  • 9
  • 30
  • 44