Skip to content

Intellisense Not Supported JSDoc Annotation @yields #169525

@LianSheng197

Description

@LianSheng197

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.74.1
  • OS Version: Ubuntu 22.04.1 LTS x86_64

Steps to Reproduce:

  1. Just write a generator function like this one:

image

As you can see, the bottom variable f doesn't get type hints for string.
This annotation is following JSDoc @generator.

At this point, if we look at the hint of parseFiles, we can see that yields doesn't seem to be interpreted correctly, and the function doesn't seem to be a generator function. (no asterisks, nor any text description for generator function)

image

  1. Current temporary solution

Replace the @yields {string} to @returns {AsyncGenerator<string>}.
Then the variable f below can correctly get the string type hint.
image

  1. Finally, this is example code:

More details:

  • Node.js v16.18.1
    • Already installed dependence @types/node.
      (But whether it is installed or not does not affect the reproduction of this problem.)
import { resolve } from "path";
import * as fs from "fs";

async function* parseFiles(dir) {
    const dirEntires = await fs.promises.readdir(dir, { withFileTypes: true });

    for (const dirent of dirEntires) {
        const res = resolve(dir, dirent.name);
        if (dirent.isDirectory()) {
            yield* parseFiles(res);
        } else {
            yield res;
        }
    }
}

(async () => {
    for await (const f of parseFiles('./public')) {
    }
})();

Metadata

Metadata

Assignees

Labels

*duplicateIssue identified as a duplicate of another issue(s)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions