Any TypeScripters out there that tried to implemen...
# suitescript
d
Any TypeScripters out there that tried to implement
decorators
?
@stalbert?
s
Umm, yes, NFT uses decorators heavily to make it clear/easy to describe netsuite records
you just declare a class with properties named after the field internal ids and mark each property with the field type via a decorator: https://github.com/ExploreConsulting/netsuite-fasttrack-toolkit-ss2/blob/master/DataAccess/CustomerBase.ts
d
Odd. The javascript that gets produced defines the __decorator before the define, and NetSuite chokes on it
Same when I try to use inheritance ... it shoves the __extends before the define and NetSuite no likey
s
not sure what you mean by no-likey because I've been using this for years without issue
so much so, that I've considered moving the helpers to their own lib (i.e. so that __extends() and friends aren't repeated)
typescript supports that notion - I just need to adopt it I guess, but I digress
perhaps notable that I compile with a
UMD
target
because our code needs to be executable in NodeJS or NS, since I run unit tests in node
if you still have issue you could try leveraging that tslib for the helpers, but that shouldn't be necessary (again, I've been using this for a few years now)
d
Hmm ..
UMD
... that might be it
wait, tsconfig.json ...
target
.. umd is no a valid option
You mean
moduleResolution
Bah, screw it. I so wanted to use decorators for logging, unit usage, etc. NetSuite doesn't like it. Thanks anyway @stalbert
s
well we know decorators work great since NFT NSDAL relies on them to its core.
Also, I'd recommend you take a look at NFT autologging - it uses an
aspect oriented programming
approach to automatically log without the user adding code.
(logs stuff such as the entry and exit of functions, with return values, arguments, execution elapsed time and governance units consumed)