I'm building a React Native app in TypeScript with Redux and Normalizr. So I will have noramlized state.
I have four interfaces: Emotion
, Need
, PainData
and PainReport
:
export interface Emotion {
name: string;
chosen: boolean;
rating: number;
}
export interface Need {
name: string;
rating: number;
}
export interface PainData {
note: string;
emotions: Emotion[];
needs: Need[];
date: Date;
}
export interface PainReport {
[date: string]: PainData
}
Now I would like to create an interface that is not an array, but an object an allows several PainReports like this (pseudo code):
export interface PseudoPainReportsObject {
[date: string]: PainData,
[date: string]: PainData,
[date: string]: PainData,
// ... dynamically have as many as I'd like. Maybe 1, maybe 100
}
I want to use this for normalized state like you get when using Normalizr.
How would one do such a type or interface?
[date: string]
allows arbitrarily many properties. It makes no sense to have that multiple times. – SylviePainReport
interface already does exactly what you want. – Sylvie