I try to cast a list of strings [x, y, z] to
a list of JSON-objects [{str:x},{str:y},{str:z}].
Thats my try, but I get an error.
let lst:string [] = ["a", "b", "c"];
let foo:any [] = lst.map (l => {"str": l});
Error
error TS1005: ';' expected.
let foo:any [] = lst.map (l => {"str": l});
~
>Solution :
While returing you need to use brackets(). Because we are inside a loop {} will be treated as block. So the updated code will be,
let lst: string[] = ["a", "b", "c"];
let foo: any[] = lst.map(l => ({ "str": l }));
Note ({"str": l})