'Interface for Array of array of numbers
I have a dataset
"series": [{
"name": "Events",
"data": [
[0,0],
[0,1],
[2,2],
...
]
}]
What's the proper Typescript interface for this? This is not quite right:
export interface MyInterface {
series: {
name: string;
data: number[]
}
}
Solution 1:[1]
I prefer to keep my typings as a single level/hierarchy, if it requires another level to describe the object, I like to create its own interface/type for that object.
Example:
export interface SeriesEvent {
[0]: number,
[1]: number
}
export interface Series {
data: SeriesEvent[]
name: "Events";
}
export interface MyInterface {
series: Series
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dallas Clark |
