closure-compiler icon indicating copy to clipboard operation
closure-compiler copied to clipboard

Allow to write typedef without variable

Open zavr-1 opened this issue 5 years ago • 3 comments

It's quite common in the Node.js world to write Typedef with JSDoc without creating any variables, e.g.,

/**
 * Parse the config and extract arguments from the `process.argv` array.
 * @param {Config} config The configuration for parsing.
 * @param {string} config.abc The test variable
 */
export function parse(config = {}) {
  const { abc } = config
  console.log(abc)
}

/**
 * @typedef {Object} Config
 * @prop {string} abc The test variable
 */

The Google Closure Compiler does not understand those types, and VS Code does not understand the compiler notation with variables. Could you make it so it's possible extract the types without variables please.

zavr-1 avatar Jan 14 '19 16:01 zavr-1

Created Google internal issue http://b/122837732

EatingW avatar Jan 14 '19 19:01 EatingW

As far as i know there isn't a way to define a type without creating variables. I've created the internal issue as a feature request, and we might revisit this in the future.

EatingW avatar Jan 14 '19 21:01 EatingW

I'd also like this. I have annotated lots of code like this for support with IntelliSense/TypeScript and this all breaks when trying to build with Closure Compiler.

jespertheend avatar Oct 28 '21 19:10 jespertheend