Does anyone use the npm package `@hitc/netsuite-ty...
# suitescript
a
Does anyone use the npm package
@hitc/netsuite-types - npm
for writing Suitescript in Typescript? If yes does anyone know how to import custom libraries or utility files with it. (Please leave out all your hateful responses to Typescript and only respond to the question šŸ˜)
a
@stalbert Will know for sure.
s
NFT (which is itself just a custom library for SuiteScript) uses hitc/netsuite-types for all the native NS
N/
modules
@Azi if you want to share a code sample of what you'd like to do but is failing, I can try and explain how to do it to make TS happy.
or, just clone the NFT repository and check out some of the code snippets there for some guidance.
m
@stalbert I think hes asking how to import a custom module in a ts file. Im guessing you would have to set a new path in the tsconfig.json and then define some module types
Meaning if the custom module is not part of your project and is just a custom module somewhere in the netsuite filecabinet
s
no need to set anything in
tsconfig.json
if you're using relative paths to reach that module e.g.
import { foo } from "../mylibs/foolib"
m
Wouldnt that give a ts error because the module doesnt exist?
s
it's probably useful to point out that
@hitc/netsuite-types
for type definitions is orthogonal to how you import custom libraries. netsuite-types is just a types description of all the native modules, no implementation.
m
Thats why i am suggesting that he may need to create the types for the module he wants to import
s
@mayerlench yes, that relative path import needs to be (and should be) at that relative path. I try to maintain the same relative path both in your local codebase and in NetSuite File Cabinet for simplicity.
aye, sounds like it would help if @Azi provides a code snippet of what they're trying.
m
Ahhh, of course. I understand
d
recently stumbled across that hitc/netsuite-types library and am loving it so far...fyi it can be used in standard amd-style JavaScript files as well šŸ˜
s
you mean via editor support for the jsdocs? or do you mean with TypeScript's support for plain js files?
in any case, I support that lib and encourage others to contribute to it to keep it up to date.
d
@stalbert yah for VSCode at least. I just followed the hitc setup guide on their github and then for any netsuite API instead of having @param {search} search you'd have @paramĀ {import('N/search')}Ā search
idk if that is "best practice" to do though or if there is a better way of getting IntelliSense support in JS files, I literally just discovered that import syntax last night ; definitely welcome to any further suggestions!
s
I helped create the readme for netsuite-types, especially the part around supporting TS 2.x. However, one thing that's changed in more recent versions of TS is it can understand jsdocs... I code in TypeScript so I haven't really needed to test that feature but supposedly current
tsc
can typecheck against JSDOC comments in pure JS files (i.e. get type checking without any TypeScript defined types anywhere to be found)
d
very cool, didn't know that was a more recent feature in general, but I have been playing around w/ the additional validation in pure JS files via checkJs setting and liking it so far. Some Docs incase anyone else is interested: https://code.visualstudio.com/docs/nodejs/working-with-javascript#_type-checking-javascript https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#import-types