Skip to content

Question about type definitions #1197

@jsumners-nr

Description

@jsumners-nr

In jsdoc type definitions are picked up regardless of the file they are defined in. Consider:

foo.js

'use strict'

/**
 * Foo is an interface not a class.
 *
 * @interface
 * @private
 */
class Foo {
  /**
   * The name of the thing.
   *
   * @type {string}
   */
  name
}

module.exports = Foo

bar.js

'use strict'

/**
 * Bar is a Foo
 *
 * @extends Foo 
 */
class Bar extends Foo {
  /**
   * The answer to everything.
   *
   * @type {number}
   */
  answer = 42

  constructor() {
    super()
    this.name = 'Bar'
  }
}

module.exports = Bar

Running jsdoc -p *.js on the above will result in an out/index.html that shows a Bar definition that links back to Foo:

image

But if we have the jsdoc/no-undefined-types rule enabled for this eslint plugin we will get an error in bar.js about Foo being undefined. I think #99 is discussing this same problem, but I'm not clear what the resolution is. Are we able to configure this plugin to work as jsdoc does?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions