Skip to content

obj is always null in error message #19

Description

@Nooka10

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";
    }
    .....
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions