skip to Main Content

I am a facade NodeJS module that simplifies interaction with the Shopify API for my backend’s needs. I have a function that returns a promise that when resolved, contains an object with the shop’s details (id, email, country, currency, etc).

I want to use JSDoc to document those properties to make the life of our devs easier (we are all using VSCode and Intellisense picks up JSDoc type definitions with zero config).

Unfortunately, the fields list returned by that API call is huge so I end up with a single line spanning multiple columns looking like this:

@return {Promise<{id, name, email, domain, province, country, address1, zip, city, source, phone, latitude, longitude, primary_locale, address2, created_at, updated_at, country_code, country_name, currency, customer_email, timezone, shop_owner, money_format, weight_unit, province_code, taxes_included.....

Is there a way to break this into separate lines and maintain both VSCode syntax highlight in the JSDoc and working Intellisense?

2

Answers


  1. If you are using typescript (I assume that from the generic definition) I’d suggest to extract the generic type into a separate interface:

    /**
     * Return type of something
     */
    interface PromiseReturnType {
        /**
         * The unique identifyer
         */
        id: number
        /**
         * JSDoc hint for the name
         */
        name: string
    }
    
    const a: Promise<PromiseReturnType> = new Promise(...)
    const props = await a
    props.id // you will get the hint here
    
    Login or Signup to reply.
  2. I know the question has been asked long ago meanwhile, but I found a solution that might be interesting fo other users:

    Simply put a <br> tag between the items you want to display in a new line.
    It works in the VS Code as well as in the created documentation!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search