Why can I initialize friends below as an empty array []
, but not do the same for session with an empty object {}
? Is there a way to use the empty object without needing to make all keys optional in the interface?
const initialState: {
friends: Array<{
name: string;
age: number;
}>;
session: {
login: string;
avatar: string;
}
} = {
friends: [], // works fine
session: {} // results in an error!
};