diff --git a/lib/Resolver.js b/lib/Resolver.js index 875b435f..93951440 100644 --- a/lib/Resolver.js +++ b/lib/Resolver.js @@ -45,10 +45,18 @@ const { * @param {T=} result */ +/** @typedef {function((NodeJS.ErrnoException | null)=, (string | Buffer)[] | IDirent[]=): void} DirentArrayCallback */ + +/** + * @typedef {Object} ReaddirOptions + * @property {BufferEncoding | null | 'buffer'} [encoding] + * @property {boolean | undefined} [withFileTypes=false] + */ + /** * @typedef {Object} FileSystem * @property {(function(string, FileSystemCallback): void) & function(string, object, FileSystemCallback): void} readFile - * @property {(function(string, FileSystemCallback<(Buffer | string)[] | FileSystemDirent[]>): void) & function(string, object, FileSystemCallback<(Buffer | string)[] | FileSystemDirent[]>): void} readdir + * @property {function(string, (ReaddirOptions | BufferEncoding | null | undefined | 'buffer' | DirentArrayCallback)=, DirentArrayCallback=): void} readdir * @property {((function(string, FileSystemCallback): void) & function(string, object, FileSystemCallback): void)=} readJson * @property {(function(string, FileSystemCallback): void) & function(string, object, FileSystemCallback): void} readlink * @property {(function(string, FileSystemCallback): void) & function(string, object, FileSystemCallback): void=} lstat diff --git a/types.d.ts b/types.d.ts index 01436533..2c0b668e 100644 --- a/types.d.ts +++ b/types.d.ts @@ -45,17 +45,31 @@ declare class CachedInputFileSystem { ): void; }; statSync: (arg0: string, arg1?: object) => FileSystemStats; - readdir: { - ( - arg0: string, - arg1: FileSystemCallback<(string | Buffer)[] | FileSystemDirent[]> - ): void; - ( - arg0: string, - arg1: object, - arg2: FileSystemCallback<(string | Buffer)[] | FileSystemDirent[]> - ): void; - }; + readdir: ( + arg0: string, + arg1?: + | null + | (( + arg0?: null | NodeJS.ErrnoException, + arg1?: (string | Buffer)[] | any[] + ) => void) + | ReaddirOptions + | "ascii" + | "utf8" + | "utf-8" + | "utf16le" + | "ucs2" + | "ucs-2" + | "base64" + | "latin1" + | "binary" + | "hex" + | "buffer", + arg2?: ( + arg0?: null | NodeJS.ErrnoException, + arg1?: (string | Buffer)[] | any[] + ) => void + ) => void; readdirSync: ( arg0: string, arg1?: object @@ -107,17 +121,31 @@ declare interface FileSystem { arg2: FileSystemCallback ): void; }; - readdir: { - ( - arg0: string, - arg1: FileSystemCallback<(string | Buffer)[] | FileSystemDirent[]> - ): void; - ( - arg0: string, - arg1: object, - arg2: FileSystemCallback<(string | Buffer)[] | FileSystemDirent[]> - ): void; - }; + readdir: ( + arg0: string, + arg1?: + | null + | (( + arg0?: null | NodeJS.ErrnoException, + arg1?: (string | Buffer)[] | any[] + ) => void) + | ReaddirOptions + | "ascii" + | "utf8" + | "utf-8" + | "utf16le" + | "ucs2" + | "ucs-2" + | "base64" + | "latin1" + | "binary" + | "hex" + | "buffer", + arg2?: ( + arg0?: null | NodeJS.ErrnoException, + arg1?: (string | Buffer)[] | any[] + ) => void + ) => void; readJson?: { (arg0: string, arg1: FileSystemCallback): void; (arg0: string, arg1: object, arg2: FileSystemCallback): void; @@ -185,6 +213,22 @@ declare interface PossibleFileSystemError { path?: string; syscall?: string; } +declare interface ReaddirOptions { + encoding?: + | null + | "ascii" + | "utf8" + | "utf-8" + | "utf16le" + | "ucs2" + | "ucs-2" + | "base64" + | "latin1" + | "binary" + | "hex" + | "buffer"; + withFileTypes?: boolean; +} /** * Resolve context