How to cast string to array of objects in Type Script?
I have following code working perfectly:
let nodes = new DataSet<any>([
{id: 1, label: 'Node 1'},
{id: 2, label: 'Node 2'},
{id: 3, label: 'Node 3'},
{id: 4, label: 'Node 4'},
{id: 5, label: 'Node 5'}
]);
But when I try to use
let nodes2 = new DataSet<any>(this.someEntity.nodesConfig);
I get following error:
TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'any[]'. Type >'undefined' is not assignable to type 'any[]'.
Here is SomeEntity:
export interface SomeEntity{
id?: string;
nodesConfig?: string;
edgesConfig?: string;
}