MakeTypes
MakeTypes copied to clipboard
obj is always null in error message
Hi,
When you use MakeType from your website, the generated Typescript proxies output contain a create function that never initialize the obj object. So in the error message, the full object is always null...
Error: TypeError: Expected number at root.id but found:
undefined
Full object:
null
That's because there is a default value for the field parameter, so the if(!field) test is always false...
public static Create(d: any, field: string = 'root'): ExampleProxy {
if (!field) {
obj = d;
field = "root";
}
.....
}
You should remove the default value and make the parameter optional:
public static Create(d: any, field?: string): ExampleProxy {
if (!field) {
obj = d;
field = "root";
}
.....
}