Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-undefined-types: false positive for template tags with defaults #887

Closed
tschaub opened this issue May 23, 2022 · 3 comments
Closed

no-undefined-types: false positive for template tags with defaults #887

tschaub opened this issue May 23, 2022 · 3 comments

Comments

@tschaub
Copy link
Contributor

tschaub commented May 23, 2022

Expected behavior

No error.

Actual behavior

The type 'F' is undefined.

ESLint Config

{
  "env": {
    "es6": true
  },
  "parserOptions": {
    "ecmaVersion": "latest",
    "sourceType": "module"
  },
  "plugins": ["jsdoc"],
  "rules": {
    "jsdoc/no-undefined-types": "error"
  },
  "settings": {
    "jsdoc": {
      "mode": "typescript"
    }
  }
}
export class Food {}

export class Soup extends Food {}

export class Donut extends Food {}

/**
 * @template {Food} [F=Soup]
 */
export class Restaurant {
  /**
   * @param {Array<F>} menu The menu items.
   */
  constructor(menu) {
    /**
     * @private
     * @type {Array<F>}
     */
    this.menu = [];
  }
}

Environment

  • Node version: v17.5.0
  • ESLint version v8.0.0
  • eslint-plugin-jsdoc version: 39.3.0

Details

When a template tag is declared like @template {Food} F, the no-undefined-types rule works. If the template tag has a default like @template {Food} [F=Soup], then the no-undefined-types rule does not work.

Support for defaults in template tags was added in TypeScript 4.5 (see microsoft/TypeScript#45483).

Previous improvements to the no-undefined-types rule when using template tags:

@gajus
Copy link
Owner

gajus commented May 24, 2022

🎉 This issue has been resolved in version 39.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@brettz9
Copy link
Collaborator

brettz9 commented May 24, 2022

I've also added a subsequent release to fix the fact that the earlier release wasn't handling defaulting template names later in a list.

@tschaub
Copy link
Contributor Author

tschaub commented May 24, 2022

Thanks for the quick fix, @brettz9!

crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this issue May 24, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) | devDependencies | patch | [`39.3.0` -> `39.3.2`](https://renovatebot.com/diffs/npm/eslint-plugin-jsdoc/39.3.0/39.3.2) |

---

### Release Notes

<details>
<summary>gajus/eslint-plugin-jsdoc</summary>

### [`v39.3.2`](https://github.com/gajus/eslint-plugin-jsdoc/releases/tag/v39.3.2)

[Compare Source](gajus/eslint-plugin-jsdoc@v39.3.1...v39.3.2)

##### Bug Fixes

-   **`no-undefined-types`:** ensure parsing takes into account template names with defaults ([374daac](gajus/eslint-plugin-jsdoc@374daac))

### [`v39.3.1`](https://github.com/gajus/eslint-plugin-jsdoc/releases/tag/v39.3.1)

[Compare Source](gajus/eslint-plugin-jsdoc@v39.3.0...v39.3.1)

##### Bug Fixes

-   update `jsdoccomment` to support default template values; fixes [#&#8203;887](gajus/eslint-plugin-jsdoc#887) ([53e4174](gajus/eslint-plugin-jsdoc@53e4174))

</details>

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1370
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants