I have an interface like so:
And a component like so:
But I am getting this error:
How can I destructure my values so that Typescript will be happy?
I have an interface like so:
And a component like so:
But I am getting this error:
How can I destructure my values so that Typescript will be happy?
In your local declarations, can you try :
@Input() accounts: Accounts;
myAccountsList: Array<AccountList>;
authorizedAccountsList: Array<AccountList>;
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>;