RicoSuter/NJsonSchema
two-dimensional arrays of objects in typescript
Aberta
#621 aberto em 11 de fev. de 2018
help wantedtype: enhancement
Métricas do repositório
- Stars
- (1.581 estrelas)
- Métricas de merge de PR
- (Mesclagem média 39d 6h) (1 fundiu PR em 30d)
Description
C# code such as
[DataContract]
public class Foo {
[DataMember] public int FooNum {get;set;}
}
[DataContract]
public class Bar {
[DataMember] public Foo[][] Foos {get;set;}
}
The issue is when creating the init method for Bar, the generated typescript will look like
...
if (data["Foos"] && data["Foos"].constructor === Array) {
this.foos = [];
for (let item of data["Foos"])
this.foos.push(item); // <------- problem here, not calling Foo.fromJS
}
...
For a one-dimensional array, the typescript correctly uses this.foos.push(Foo.fromJS(item)). This isn't high priority for me since I was able to remove two-dimensional arrays and instead create an intermediate class. I don't know how much you want to fix here, support many array dimensions?