question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support JSDoc `@property`

See original GitHub issue

From @BrunnerLivio on May 8, 2017 9:1

  • VSCode Version: 1.12.1
  • OS Version: Ubuntu 16.04.1 LTS (Xenial Xerus)

Example code: MyController.js

// @ts-check
class MyController {
    getWorld() {
        return this.world; // <--- Marked as error
    }
}
angular
    .module('myApp')
    .component('myComponent', {
        bindings: {
            'world': '<'
        },
        controller: MyController,
        template: `<div>Hello {{$ctrl.getWorld()}}</div>`
    });


The this.world is marked as error, as supposed to be. But it is actually pretty annoying, because in angular you need to use quite often those component bindings. I know there’s the option // @ts-ignore, but that really pollutes the code and makes it less readable.

An extensions for this would be really useful.

I use this workaround at the moment

// @ts-check
class MyController {
    constructor() {
        this.world = this.world;
    }
    getWorld() {
        return this.world;
    }
}

[...]

I don’t like this at all, but better than writing // @ts-ignore.

Is there any other option / workaround?

Copied from original issue: Microsoft/vscode#26192

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:8
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

10reactions
mhegazycommented, May 10, 2017

@property would be the best way to go i would say.

3reactions
PavelPolyakovcommented, Nov 9, 2018

alright, I’d duplicate my case here:

// my-new-type.js

/**
 * MyNewType
 * @typedef {Object} MyNewType
 * @property {Factory~logFirst} logFirst
 * @property {Factory~logSecond} logSecond
 */

/**
 * MyNewType factory
 * @constructor
 * @param {number} first
 * @param {number} second
 * @returns MyNewType
 */
function Factory(first, second) {
  /**
   * logs first argument
   * @param {number} times
   */
  function logFirst(times) {
    for (let i = 0; i < times; i++) {
      console.log(first);
    }
  }

  /**
   * logs second argument
   * @param {number} times
   */
  function logSecond(times) {
    for (let i = 0; i < times; i++) {
      console.log(second);
    }
  }

  return {
    logFirst,
    logSecond
  };
}

module.exports = Factory;

The example above currently doesn’t work, since it “does not see” child methods.

it’s not only about @property, but about supporting jsdoc namepath as well. http://usejsdoc.org/about-namepaths.html

Thanks for creating a great product.

Regards,

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use JSDoc: @property
The @property tag is a way to easily document a list of static properties of a class, namespace or other object. Normally JSDoc...
Read more >
JSDoc Reference - TypeScript: Documentation
JSDoc Reference. The list below outlines which constructs are currently supported when using JSDoc annotations to provide type information in JavaScript files.
Read more >
jsdoc @property does not support default values
When writing a javascript jsdoc comment, if you specify a default value for a property it's not shown in intellisense. Example:
Read more >
JsDoc support
@property and @member — used to describe properties as part of a @typedef type declaration. See above for an example. Type Syntax. Visual...
Read more >
jsDoc | Add support for optional properties in @typedef with ...
jsDoc | Add support for optional properties in @typedef with @property. 2. I have next code. /** * @typedef {object} MyType * @property...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found