Does anyone know where to find a SS2.0 JSDOC definition library?

后端 未结 2 498
盖世英雄少女心
盖世英雄少女心 2021-01-14 13:06

Does anyone know or has a JSDOC definition library I can use for SS2.0??

The current one I have for SS1.0 looks like the one below, and I use it to plug into my IDE

相关标签:
2条回答
  • 2021-01-14 13:51

    You may consider what I did which there is no need to download other plugins.
    You will be able to enable the code assist if you have the copy of SS2.0 API and then use "@param" and "@type" JSDOC tag.
    Then, there will be suggestion every time you type then 'CTRL' + 'SPACE".
    Aside from that, your IDE will also provide description for each function.
    So this is what will you do.


    1. On your NetSuite accoun, download the SuiteScript 2.0 JavaScript files. You can do this by nagaviting at >Documents>Files>SuiteScripts>. Then at right portion of your screen, you should see links for "SuiteScript 2.0 API" and "SuiteSCript 1.0 API". Click for SS2.0 to download.
    2. On Eclipse IDE, create a new JavaScript project for SS2.0 or include it on your existing project.
    3. Next on the project you are working, right click then select “Properties”. Under >JavaScript>Include Path and then at “Projects” subtab, add the project where SS2.0 APIs are included.
    4. You will now have code assist for object literal APIs of SS2.0. These are 'N/log' and 'N'util' modules.
    5. Next to enable the code assist for object constructor APIs of SS2.0 like 'N/record' and 'N/search' modules, we should be adding "@param" JSDoc tag on each function declaration.

      So if we are going to use the 'N/record', 'N/search' and 'N/error' modules in our script, we should have below sample comments before function declaration. But please take note that it should match the value inside the "{[VALUE HERE]}" tag and the module name. Also the variable name on the comment section and function declaration.

      /**
      * Do something.
      * 
      * @param {record} objRec
      * @param {search} objSearch
      * @param {error} objError
      * 
      */
      function doSomething(objRec, objSearch, objError)
      {
             //CODE HERE
      }
      


      You may also use '@type' for your variable declaration. Below is the sample code.

      /**
      * Do something.
      * 
      */
      function doSomething()
      {
             /*** @type record**/
             var recCustomerRefund = record.create(
                  {
                      type : 'customerrefund',
                      isDynamic : true
                  }); 
      }
      

    0 讨论(0)
  • 2021-01-14 13:55

    The way SS2 works you are essentially out of luck.

    consider

    define(['N/search'], function(bob){
        var srch = bob.load({id:'customsearch_my_search'});
    }
    

    What is bob? Your IDE will have to be considerably smarter to know that bob is part of the search namespace. It's of course doable but less likely to work with a simple downloadable file that you can just plug into your IDE. If you just use 'search' that may make things more likely to work but now you've used up a very generic name that you cannot use elsewhere.

    Also if an IDE can determine what 'bob' is now your arguments is an unordered hash so positional @params don't work anymore.

    Typescript may help. I've been maintaining a Typescript definition file for SS1 at https://github.com/BKnights/KotN-Netsuite. As I start doing more with SS2.0 I may do the same for that. Then your IDE would have more of a chance:

    define(['N/search'], function(bob:NSearch){...
    

    So your Typescript aware IDE could use that for member completion and at least you'd have a compile time check on types

    0 讨论(0)
提交回复
热议问题