Skip to content

Commit

Permalink
fix(support): force type of promisified read()
Browse files Browse the repository at this point in the history
  • Loading branch information
boneskull committed Oct 31, 2022
1 parent 0617492 commit aa415bc
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/support/lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,10 @@ const fs = {
open: B.promisify(open),
openFile: fsPromises.open,
readdir: fsPromises.readdir,
read: B.promisify(read),

read: /**
* @type {ReadFn<NodeJS.ArrayBufferView>}
*/ (/** @type {unknown} */ (B.promisify(read))),
readFile: fsPromises.readFile,
readlink: fsPromises.readlink,
realpath: fsPromises.realpath,
Expand Down Expand Up @@ -390,3 +393,14 @@ export default fs;
* @typedef {import('mv')} mv
* @typedef {import('fs').PathLike} PathLike
*/

/**
* @template {NodeJS.ArrayBufferView} TBuffer
* @callback ReadFn
* @param {number} fd
* @param {TBuffer|import('node:fs').ReadAsyncOptions<TBuffer>} buffer
* @param {number} [offset]
* @param {number} [length]
* @param {number?} [position]
* @returns {B<{bytesRead: number, buffer: TBuffer}>}
*/

0 comments on commit aa415bc

Please sign in to comment.