I'm working on my first typescript SCA site. I kno...
# suitecommerce
g
I'm working on my first typescript SCA site. I know typescript well, and it seems extensions are still straight .js. Is there any documentation on typescript customisation, and how to extend a typescript view from an extension, e.g. wrapping the getContext function?
e
Currently there is no way to use typescript in extensions, you need to use the extensibility API , there could be some specific scenarios in which you may need to extend files but NetSuite do no recommend that as best practice. If you need it and know what you are doing, just extend them as they were .js files.
g
yep, normally I would use _.wrap(....
But that doesn't seem to be an option anymore.
Ah I think I've got it... wrap view.prototype.constructor.method
f
We’re not exposing TypeScript definitions, so we don’t have this documented. If you want to use TypeScript, you will have to generate your own definitions of our modules, that may be “empty”, to be able to compile. Regardless that, “wrapping the getContext function” is a bad practice that must be avoided. The right way is using addToViewContextDefinition method which is available in all the VisualComponents including LayoutComponent.
g
Thanks for the pointers. addToViewContextDefinition is probably what I was looking for. But what if I wanted to wrap initialize or some other function. I do that a lot. Is _.wrap( not best practice any more?
f
It was never a good practice, but in SCA you can do it with very low risk as you do not receive automatic upgrades