so I have a model:
export interface Clan {
name: string;
members: [string];
invitees: [string];
}
When the user creates a new clan it does not has yet invitees, only one member.
newClan = {
name: form.value.name;
members: [user.id];
invitees: [];
}
And this gives the an error
Property '0' is missing in type '[]' but required in type '[string]'.
Of course I could use values as null or undefined, also or just define invitees in the model as not required:
export interface Clan {
name: string;
members: [string];
invitees?: [string];
}
But is there a way to have an invitees empty array on the creation of a new clan?
[string]is how you declare a tuple that will contain a string in typescript, at least the start of a tuple. Usually, you will have more than one type in a tuple.string[]is how you declare an array of type string.