Is there a way to write a reusable class (consumed...
# suitescript
s
Is there a way to write a reusable class (consumed by NAmdConfig) where I don't have to do
new Customer.Customer()
, but can instead just skip the first one and do
new Customer()
?
b
what does the reusable class look like
s
Copy code
/**
 * @NModuleScope public
 */
define([], function () {
    class Customer {
        entityId;
        internalId;
        daysoverdue;
        creditlimit;
        balance;
        custentity_mhi_ad_grace_period;
        tranId;
        transactionId;

        /**
         * @param{Customer} customer
         */
        constructor(customer) {
            Object.assign(this, customer);
        }
    }

    /**
     * @module Customer
     */
    return { Customer };
});
b
Copy code
return Customer
return the Customer class, not an object containing the Customer class
s
I did that, but the code completion doesn't seem to understand it
How would you get webstorm to recognize the code complete?
This doesn't do anything
Copy code
/**
     @class Customer
     @module Customer
     */
    return Customer;
b
its probably the amd config you did
you would have to explicitly define the type of the parameter since webstorm isnt parsing your config
s
this is my config
Copy code
{
  "paths": {
    "Customer": "/SuiteScripts/AccentDecor/Libs/Models/Customer.js"
  }
}
b
doesnt really matter, webstorm isnt reading it
s
True. Any idea on how to explicitly define the type so that webstorm reads it?
b
c
You could also just make a constructor function like function Customer(dataIn) {} and not deal w/ all of it.
Seems like a bit of overengineering
s
The class does have a constructor. Are you saying export the class and just deal with the new customer.customer?