0
votes

I can not solve the problem of type compatibility. Problem is there:

this.options.list.push(...this.cloudData.map((e: Words) => [e.word, e.size] as[string, number]) as[string, number][]);

options: Options = {
  list: [] as ListEntry
};

where ListEntry is:

type ListEntry = [string, number];

And Error is:

error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((...items: any[]) => number) | ((...items: [string, number][]) => number)' has no compatible call signatures.

Any ideas?


EDIT

Words type:

export class Words {
  word: string;
  size: number;
}
1
It might be because options.list is expecting a string as its first entry but you're giving it an array. - Joseph Webber
Can you please add the type Words? - ariels
Is added now, sorry - Blackboy
What is the Options type. Your code mostly works for me the only issue is that list field should be list: [] as ListEntry[] typescriptlang.org/play/… - Titian Cernicova-Dragomir
@TitianCernicova-Dragomir thanks its working - Blackboy

1 Answers

1
votes

Solved in comments, add so this does not remain unanswered:

Your initialization of list is off. Form your usage list should be an array of ListEntry

let options = {
  list: [] as ListEntry[]
};