Home > Blockchain >  Source has 5 element(s) but target allows only 0
Source has 5 element(s) but target allows only 0

Time:12-20

The typescript show this error:

Source has 5 element(s) but target allows only 0

Test.ts

await Map.createPoint("New York",[[323, 232],
      [123, 233],
      [221, 455],
      [321, 212],
      [122, 253]]);

Map.ts


class Map{
  async createGeofencesTest(city:string,points:[]): Promise<void> {
    await Admin.setGeofenceCity(city); 
    await Admin.Points(points);
return;
}
}

what am I doing wrong?

CodePudding user response:

The type [] is an array with 0 elements. You need either number[][] or [number, number][].

number[][] is an array of arrays of numbers.

[number, number][] is an array of [number, number]. [number, number] is an array with exactly two numbers.

CodePudding user response:

Array<Array<number>>
  • Related