I have a response-redux application written in typescript with an immutable package. There I have data that comes from the api and in the store I pack it into Map. In all applications they are used as a map.
I created an interface:
export interface PaymentMethod extends Immutable.Map<string, string | NamedType<number>> {
id: string;
name: string;
description: string;
accountNr: string;
paymentMethodType: NamedType<number>;
}
In general, it works very well. Other than tests, where I create data this way:
const dummyPaymentMethod: PaymentMethod = Map({
id: '',
name: '',
description: '',
accountNr: '',
paymentMethodType: { id: 1, name: '' },
});
and then I get lint error:
Error:(116, 13) TS2322:Type 'Map<string, string | { id: number; name: string; }>' is not assignable to type 'PaymentMethod'.
Property 'id' is missing in type 'Map<string, string | { id: number; name: string; }>'.
I feel completely lost since I can see the id in the interface and in my dummy data.
I would take care of him. I feel that somehow I have to pass a list of acceptable keys to my Card, but I donβt know how to do it.
EDIT: misspell
Kania source
share