builder-pattern icon indicating copy to clipboard operation
builder-pattern copied to clipboard

Does this library support class method?

Open Sol-cito opened this issue 1 year ago • 1 comments
trafficstars

Hi. Thanks for this great library.

I've been using it for my side project, and encountered a problem.

My class looks like:

export class MyClass {
  id:number;
  public method(){};
}

I created a class instance by using builder as below:

const myClass: MyClass =
  Builder<MyClass>()
        .id(1)
        .build();

I expected the instance would have the class method but the object does not have any method.

Does build method only support field properties, not the method?

Regards,

Sol-cito avatar Mar 15 '24 14:03 Sol-cito

try this:

const myClass =
  Builder(MyClass)
        .id(1)
        .build();

see the docs

pyoner avatar Mar 16 '24 05:03 pyoner