Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using d.ts files for autocompletion on non typescript files #220

Open
Grimi94 opened this issue Sep 15, 2022 · 1 comment
Open

Using d.ts files for autocompletion on non typescript files #220

Grimi94 opened this issue Sep 15, 2022 · 1 comment

Comments

@Grimi94
Copy link

Grimi94 commented Sep 15, 2022

Hello! I have use the library to work on typescript files and everything works great but recently I had to go back to a few files that are written on JS and I have been trying to get autocompletion to work.

For now I was able to get it working with a solution based on this link:
https://blog.8bitzen.com/blog/23-09-2022-using-jsconfig.json

It consists of adding JSDocs pointing to the d.ts files like so:

/**
 * @NApiVersion 2.1
 * @NScriptType Restlet
 * @NModuleScope SameAccount
 */
define(['N/log', 'N/search'],
/**
 * @param {import('../../../node_modules/@hitc/netsuite-types/N/log')} log
 * @param {import('../../../node_modules/@hitc/netsuite-types/N/search')} search 
 */
       function (log, search) {

Which seems a little bit hacky but allows autocompletion to work

Screen Shot 2022-09-15 at 5 47 37 PM

Is there another approach to make this work?

@dylbarne
Copy link

if you add the paths section as shown in the README on here, then you don't have to have the relative import paths
can then just have @param {import('N/search')} search
but agreed the import syntax (https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#import-types) is the general approach to get working
here is my jsconfig.json:

{
    "compilerOptions": {
		"target": "ES2020",
		"module": "ESNext",
		"moduleResolution" :"node",
		"checkJs": true,
		"baseUrl": ".",
		"paths": {
			"N": ["node_modules/@hitc/netsuite-types/N"],
			"N/*": ["node_modules/@hitc/netsuite-types/N/*"]
		}
	},
	"exclude": ["node_modules"]
}

(mainly the checkJs, baseUrl, & paths part as important)

which parts do you consider "hacky" or are unsatisfied with approach to getting the SuiteScript modules autocompletion to work in pure JS projects?
(I just use non-TS in NetSuite development as well, so I am interested as well if there is better setup options too)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants