0

I am trying to convert the following interface to JSDoc

export interface Payload {
    [key: string]: any;
    level?: string;
    code?: number;
}

so by conversion, it looks like

/**
 * @typedef Payload
 * @type {Object}
 * @property {string} [level]
 * @property {number} [code]
 */

But how do I add the option to also add any field there? How to convert [key: string]: any;?

lepsch
  • 8,927
  • 5
  • 24
  • 44
eliezra236
  • 547
  • 1
  • 4
  • 16

1 Answers1

1

Declare it like the following snippet. It's the same syntax as in Typescript.

/**
 * @typedef {{
 *   [key: string]: any;
 *   level?: string;
 *   code?: number;
 * }} Payload
 */
lepsch
  • 8,927
  • 5
  • 24
  • 44