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

enh: requirejs types but NetSuite AMD style #216

Open
gillyspy opened this issue Aug 24, 2022 · 0 comments
Open

enh: requirejs types but NetSuite AMD style #216

gillyspy opened this issue Aug 24, 2022 · 0 comments

Comments

@gillyspy
Copy link

gillyspy commented Aug 24, 2022

might be useful to incorporate the types for requirejs with a few tweaks such as:

module.d.ts

//  RequireModule from requirejs 👇🏻
 type NetsuiteRequireModule = RequireModule & {
  id: string;
  url: string;
  exports: any;
};

this makes it easier to use module (e.g. config etc) and thus NAmdConfig)

import { id, config } from 'module';

const { somevalue } = config();

export { id, somevalue };

compiles to:

define(["require", "exports", "module"], function (require, exports, module_1) {
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.somevalue = exports.id = void 0;
    Object.defineProperty(exports, "id", { enumerable: true, get: function () { return module_1.id; } });
    const { somevalue } = (0, module_1.config)();
    exports.somevalue = somevalue;
});

I'm doing this in projects individually but will either fork or PR something about this depending upon feedback .

Note: since it's a native module you can combine this with a tsconfig.json#paths.module setting of ["node_modules/@hitc/netsuite-types/module"]

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

1 participant