Reputation: 3771
I have the following code:
export const notesService = {
getChannelOptions(): ChannelOption[] {
return [...channelOptions];
},
getChannelLabelFromValue(value: string): string {
let x =this.getChannelOptions();
x = x + 3;
const label = channelOptions.filter(co => co.value === value);
return label[0] ? label[0].label : "";
}
}
The question is what must I do that flow throws an error when I try to add 3 to an array.
BTW: it works if I declare getChannelOptions outside noteService as a function.
Upvotes: 0
Views: 123
Reputation: 111
I had solved it using by explicitly declaring but there could be potentially a better approach
let x = notesService.getChannelOptions();
Upvotes: 1