-2

I want to declare a variable that is an object filled with arrays of objects for example:

let obj = {
    "page1"     : [ {x: 1, y: 2}, {x: 2, y: 5} ],
    "page2"     : [ {x: 1, y: 2}, {x: 2, y: 5} ],
    "dsfsfffsfs": [ {x: 1, y: 2}, {x: 2, y: 5} ]
}

How can I declare that as an interface in typescript?

Chris Hansen
  • 7,813
  • 15
  • 81
  • 165

1 Answers1

0

for useState and React, try this:

export interface Obj {
  x: number;
  y: number;
}

and then:

 const [objList, setObjList] = useState<Obj[]>([]);