michoel
12/07/2020, 10:31 PM/// <reference path=""
. I can't remember the actual syntax and am struggling to get it working. Does anyone have this working?
Slack Conversationstalbert
12/07/2020, 10:39 PMtsconfig.json
instead of cluttering your actual source code with typescript directivesmichoel
12/07/2020, 10:45 PMstalbert
12/07/2020, 10:50 PMstalbert
12/07/2020, 10:50 PMstalbert
12/07/2020, 10:51 PMmichoel
12/07/2020, 11:05 PMstalbert
12/07/2020, 11:53 PMstalbert
12/07/2020, 11:54 PMtsconfig.json
example is the path pointing to where the hitc/netsuite-types live (i.e. under node_modules/...(stalbert
12/07/2020, 11:54 PMstalbert
12/07/2020, 11:54 PMAzi
12/08/2020, 3:20 PMstalbert
12/08/2020, 3:26 PMAzi
12/08/2020, 3:42 PMmichoel
12/08/2020, 11:26 PM"allowJs": true,
"checkJs": true,
to the tsconfig.json
from the hitc project and then using in script as follows:
/**
* @typedef { import("N/types").EntryPoints.Suitelet.onRequestContext } onRequestContext
* @typedef { import("N/runtime") } N_runtime
*/
define(["N/runtime"], /**
*
* @param {N_runtime} runtime
* @return {any} exports
*/ function (runtime) {
return {
/**
*
* @param {onRequestContext} context
*/
onRequest(context) {
context.response.write(`Hello ${runtime.getCurrentUser().name}`);
},
};
});
michoel
12/08/2020, 11:29 PMstalbert
12/08/2020, 11:32 PMstalbert
12/08/2020, 11:33 PMstalbert
12/08/2020, 11:34 PMstalbert
12/08/2020, 11:35 PMmichoel
12/08/2020, 11:42 PMdbarnett
12/09/2020, 12:10 AMdbarnett
12/09/2020, 12:11 AM{
"compilerOptions": {
"target": "es5",
"module": "amd",
"moduleResolution" :"node",
"checkJs": true,
"baseUrl": ".",
"paths": {
"N": ["node_modules/@hitc/netsuite-types/N"],
"N/*": ["node_modules/@hitc/netsuite-types/N/*"]
}
},
"exclude": ["node_modules"],
"typeAcquisition": {
"include": [
"underscore",
"jquery",
]
}
}
michoel
12/09/2020, 12:13 AMimport
within the @param
directive. That looks much cleaner to medbarnett
12/09/2020, 12:13 AMdbarnett
12/09/2020, 12:16 AMglobals.d.ts
at the root of our projects to provide access to global modules without explicit dependency inclusion :
declare function define(...args: any[]): any;
declare function require(...args: any[]): any;
interface LogOptions {
/** String to appear in the Title column on the Execution Log tab of the script deployment. Maximum length is 99 characters. */
title?: string;
/**
* You can pass any value for this parameter.
* If the value is a JavaScript object type, JSON.stringify(obj) is called on the object before displaying the value.
* NetSuite truncates any resulting string over 3999 characters.
*/
details: any;
}
interface LogFunction {
(title: string, details: any): void;
(options: LogOptions): void;
}
declare namespace log {
var debug: LogFunction;
var audit: LogFunction;
var error: LogFunction;
var emergency: LogFunction;
}
declare namespace util {
function isArray(obj: any): obj is any[];
function isBoolean(obj: any): obj is boolean;
function isDate(obj: any): obj is Date;
function isNumber(obj: any): obj is number;
function isObject(obj: any): obj is object;
function isRegExp(obj: any): obj is RegExp;
function isString(obj: any): obj is string;
function isFunction(obj: any): obj is Function;
}
I am not sure there is a better way than this ... but I am not a ts guru
looks like is documented somewhat in this issue as well: https://github.com/headintheclouddev/typings-suitescript-2.0/issues/103michoel
12/09/2020, 12:22 AMmichoel
12/09/2020, 12:23 AM@param
works, but eslint doesn't like it...michoel
12/09/2020, 12:23 AMdbarnett
12/09/2020, 12:23 AMdbarnett
12/09/2020, 12:25 AMmichoel
12/09/2020, 12:31 AMmichoel
12/09/2020, 12:32 AMvalid-jsdoc
. Now I've changed to to eslint-plugic-jsdoc
and still complaining about the import syntaxmichoel
12/09/2020, 12:32 AM{
"parserOptions": {
"ecmaVersion": 2018
},
"plugins": [
"jsdoc"
],
"extends": [
"eslint:recommended",
"google",
"prettier",
"plugin:jsdoc/recommended"
],
"env": {
"amd": true
},
"rules": {
"valid-jsdoc": "off"
},
"globals": {
"log": "readonly"
}
}
dbarnett
12/09/2020, 12:33 AMmichoel
12/09/2020, 12:33 AMmichoel
12/09/2020, 12:34 AMmichoel
12/09/2020, 12:35 AMstalbert
12/09/2020, 4:23 AMdbarnett
12/09/2020, 12:45 PM