-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
JSDoc support for @yields #23857
Comments
Just to weigh in here, sounds like a bug on the ESLint side as well. |
|
It's an interface (well, suite of them) defining the shape of a generator or interface IteratorResult<T> {
done: boolean;
value: T;
}
interface Iterator<T> {
next(value?: any): IteratorResult<T>;
return?(value?: any): IteratorResult<T>;
throw?(e?: any): IteratorResult<T>;
}
interface Iterable<T> {
[Symbol.iterator](): Iterator<T>;
}
interface IterableIterator<T> extends Iterator<T> {
[Symbol.iterator](): IterableIterator<T>;
} |
Thank you @weswigham for the response. I already noticed that (that's the reason why I used it in the JSDoc part). I wanted to know if there were such definition in a standard way, just like You solved my question anyway, thanks again! |
Motivation: * Fix ipfs/js-ipfs#4080 * tl;dr * fix `import globSourceImport from 'ipfs-utils/src/files/glob-source.js'` from typescript * fix importing ipfs-core from typescript Context: * microsoft/TypeScript#23857 Strategy * Use jsdoc `@return` instead of `@yields` because tsc doesn't understand that `@yields` implies a `@return` type Test Case * gobengo/ipfs-core-esm-test#3 * I tested locally with `npm link` and this seemed to fix it
The /**
* @template {boolean} [E=null]
* @template {boolean} [A=null]
* @template {boolean} [T=null]
* @template {boolean} [C=null]
* @param {Node} root Root node to walk
* @param {Object} filter Tree walking options
* @param {E} [filter.element] Yield elements
* @param {A} [filter.attribute] Yield attributes
* @param {T} [filter.text] Yield Text node
* @param {C} [filter.comment] Yield Comment nodes
* @yields {
* (E extends null ? null : Element) |
* (A extends null ? null : Attr) |
* (T extends null ? null : Text) |
* (C extends null ? null : Comment)
* }
* @return {Iterable<
* (E extends null ? null : Element) |
* (A extends null ? null : Attr) |
* (T extends null ? null : Text) |
* (C extends null ? null : Comment)
* >} Iterable
*/
export function* iterateNodes(root, filter = {}) { I have TS syntax in my JSDoc, so I have disabled Edit: Intellisense (TS) parses it fine as well. Tooltip documentation bug is filed here: microsoft/vscode#164888 Edit2: I think I'm supposed to use |
Seems so. Works on my side like that. /** Runs `forEach()` callback over warehouses cache
*
* @returns {Generator<EqShowItem>}
*/
export function* forEachWarehouse() {
// …
} And then |
It would be nice to be able to use the
@yields
JSDoc tag.We work with JS and JSDoc, but taking advantage of TSC and VSCode.
We also use the valid-jsdoc eslint rule.
We have:
We want to
We can't do
Because it doesn't
return
, butyield
s, and eslint complains about it. We can disable the rule here, but it is not the desirable scenario.The text was updated successfully, but these errors were encountered: