Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

174
Vistas
jsdoc to auto use description field

I have an object like this:

resource.foo= {
  name: "Foo",
  desc: "Some description"
}

I find myself writing:

/**
 * Some description
 */
resource.foo= {
  name: "Foo",
  desc: "Some description"
}

Anyway to get the desc field automatically without copying and pasting?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Here is another way to do it, with a keybonding. Using an extension I wrote, Find and Transform, put this into your keybindings.json:

{
  "key": "alt+d",                   // whatever keybinding you want
  "command": "findInCurrentFile",
  "args": {
    "preCommands": [
      "editor.action.jumpToBracket",
      "editor.action.selectToBracket",
      "editor.action.clipboardCopyAction",
      "editor.action.insertLineBefore"
    ],
    "replace": [
      "$${",
        "return `/**\n * ` + ${CLIPBOARD}.desc  + `\n */`",
      "}$$",
    ],
    "postCommands": "cancelSelection"
  }
}

You can run javascript in the replace, and yours is pretty easy:

${CLIPBOARD}.desc since the clipboard will be the object.

jsdoc with description from object

Note the cursor must be somewhere inside the object - that is, within the brackets/braces.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Sounds impossible to me. But if all you need is to show the description in VS Code's hints, here is the closest possible solution I could come up with:

const resource = {}

const desc = 'Some description'

resource.foo= {
  name: "Foo",
  /** @type {desc} */ desc,
}

First declare desc as a constant, and you'll be able to reference the constant type. Now you should be able to see the description shows in VS Code's type hints:

enter image description here

When you are trying to type resource.foo.desc you'll also see the description:

enter image description here

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda