From 13e2c9ba90f8f34efc13fb2c3ea91affd606c5a3 Mon Sep 17 00:00:00 2001 From: Benjamin Goering <171782+gobengo@users.noreply.github.com> Date: Tue, 19 Apr 2022 14:46:35 +0200 Subject: [PATCH] fix: swap @yields for @returns (#178) Motivation: * Fix https://github.com/ipfs/js-ipfs/issues/4080 * tl;dr * fix `import globSourceImport from 'ipfs-utils/src/files/glob-source.js'` from typescript * fix importing ipfs-core from typescript Context: * https://github.com/microsoft/TypeScript/issues/23857 Strategy * Use jsdoc `@return` instead of `@yields` because tsc doesn't understand that `@yields` implies a `@return` type Test Case * https://github.com/gobengo/ipfs-core-esm-test/pull/3 * I tested locally with `npm link` and this seemed to fix it --- src/files/glob-source.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/files/glob-source.js b/src/files/glob-source.js index 4e37f08..23ac62e 100644 --- a/src/files/glob-source.js +++ b/src/files/glob-source.js @@ -18,7 +18,12 @@ const errCode = require('err-code') * @param {boolean} [options.preserveMtime] - preserve mtime * @param {number} [options.mode] - mode to use - if preserveMode is true this will be ignored * @param {import('ipfs-unixfs').MtimeLike} [options.mtime] - mtime to use - if preserveMtime is true this will be ignored - * @yields {Object} File objects in the form `{ path: String, content: AsyncIterator }` + * @returns {AsyncGenerator<{ + * path: string; + * content: AsyncIterable | undefined; + * mode: number | undefined; + * mtime: import("ipfs-unixfs/types/src/types").MtimeLike | undefined; + * }, void, unknown>} File objects that match glob */ module.exports = async function * globSource (cwd, pattern, options) { options = options || {}