mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
fs: fix typings
PR-URL: https://github.com/nodejs/node/pull/53626 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
87167fa248
commit
2fb7cc9715
2 files changed
+18
-18
No files matched your search
@@ -254,7 +254,7 @@ function exists(path, callback) {
|
||||
validateFunction(callback, 'cb');
|
||||
|
||||
function suppressedCallback(err) {
|
||||
callback(err ? false : true);
|
||||
callback(!err);
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -759,8 +759,8 @@ function readSync(fd, buffer, offsetOrOptions, length, position) {
|
||||
* @param {(
|
||||
* err?: Error,
|
||||
* bytesRead?: number,
|
||||
* buffers?: ArrayBufferView[];
|
||||
* ) => any} callback
|
||||
* buffers?: ArrayBufferView[]
|
||||
* ) => any} callback
|
||||
* @returns {void}
|
||||
*/
|
||||
function readv(fd, buffers, position, callback) {
|
||||
@@ -813,9 +813,9 @@ function readvSync(fd, buffers, position) {
|
||||
* @param {number | null} [position]
|
||||
* @param {(
|
||||
* err?: Error,
|
||||
* bytesWritten?: number;
|
||||
* bytesWritten?: number,
|
||||
* buffer?: Buffer | TypedArray | DataView
|
||||
* ) => any} callback
|
||||
* ) => any} callback
|
||||
* @returns {void}
|
||||
*/
|
||||
function write(fd, buffer, offsetOrOptions, length, position, callback) {
|
||||
@@ -891,6 +891,8 @@ ObjectDefineProperty(write, kCustomPromisifyArgsSymbol,
|
||||
* length?: number;
|
||||
* position?: number | null;
|
||||
* }} [offsetOrOptions]
|
||||
* @param {number} [length]
|
||||
* @param {number} [position]
|
||||
* @returns {number}
|
||||
*/
|
||||
function writeSync(fd, buffer, offsetOrOptions, length, position) {
|
||||
@@ -1084,14 +1086,11 @@ function truncateSync(path, len) {
|
||||
}
|
||||
// Allow error to be thrown, but still close fd.
|
||||
const fd = fs.openSync(path, 'r+');
|
||||
let ret;
|
||||
|
||||
try {
|
||||
ret = fs.ftruncateSync(fd, len);
|
||||
fs.ftruncateSync(fd, len);
|
||||
} finally {
|
||||
fs.closeSync(fd);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1450,8 +1449,8 @@ function readdirSyncRecursive(basePath, options) {
|
||||
* }} [options]
|
||||
* @param {(
|
||||
* err?: Error,
|
||||
* files?: string[] | Buffer[] | Dirent[];
|
||||
* ) => any} callback
|
||||
* files?: string[] | Buffer[] | Dirent[]
|
||||
* ) => any} callback
|
||||
* @returns {void}
|
||||
*/
|
||||
function readdir(path, options, callback) {
|
||||
@@ -1957,13 +1956,11 @@ function lchmodSync(path, mode) {
|
||||
|
||||
// Prefer to return the chmod error, if one occurs,
|
||||
// but still try to close, and report closing errors if they occur.
|
||||
let ret;
|
||||
try {
|
||||
ret = fs.fchmodSync(fd, mode);
|
||||
fs.fchmodSync(fd, mode);
|
||||
} finally {
|
||||
fs.closeSync(fd);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2838,7 +2835,7 @@ function realpath(p, options, callback) {
|
||||
|
||||
// On windows, check that the root exists. On unix there is no need.
|
||||
if (isWindows && !knownHard.has(base)) {
|
||||
fs.lstat(base, (err, stats) => {
|
||||
fs.lstat(base, (err) => {
|
||||
if (err) return callback(err);
|
||||
knownHard.add(base);
|
||||
LOOP();
|
||||
|
||||
Vendored
+6
-3
@@ -57,7 +57,7 @@ declare namespace InternalFSBinding {
|
||||
}
|
||||
|
||||
function access(path: StringOrBuffer, mode: number, req: FSReqCallback): void;
|
||||
function access(path: StringOrBuffer, mode: number, req: undefined, ctx: FSSyncContext): void;
|
||||
function access(path: StringOrBuffer, mode: number): void;
|
||||
function access(path: StringOrBuffer, mode: number, usePromises: typeof kUsePromises): Promise<void>;
|
||||
|
||||
function chmod(path: string, mode: number, req: FSReqCallback): void;
|
||||
@@ -70,7 +70,7 @@ declare namespace InternalFSBinding {
|
||||
function chown(path: string, uid: number, gid: number): void;
|
||||
|
||||
function close(fd: number, req: FSReqCallback): void;
|
||||
function close(fd: number, req: undefined, ctx: FSSyncContext): void;
|
||||
function close(fd: number): void;
|
||||
|
||||
function copyFile(src: StringOrBuffer, dest: StringOrBuffer, mode: number, req: FSReqCallback): void;
|
||||
function copyFile(src: StringOrBuffer, dest: StringOrBuffer, mode: number, req: undefined, ctx: FSSyncContext): void;
|
||||
@@ -154,7 +154,7 @@ declare namespace InternalFSBinding {
|
||||
function mkdir(path: string, mode: number, recursive: false, usePromises: typeof kUsePromises): Promise<void>;
|
||||
|
||||
function open(path: StringOrBuffer, flags: number, mode: number, req: FSReqCallback<number>): void;
|
||||
function open(path: StringOrBuffer, flags: number, mode: number, req: undefined, ctx: FSSyncContext): number;
|
||||
function open(path: StringOrBuffer, flags: number, mode: number): number;
|
||||
|
||||
function openFileHandle(path: StringOrBuffer, flags: number, mode: number, usePromises: typeof kUsePromises): Promise<FileHandle>;
|
||||
|
||||
@@ -176,6 +176,8 @@ declare namespace InternalFSBinding {
|
||||
function readdir(path: StringOrBuffer, encoding: unknown, withFileTypes: true, usePromises: typeof kUsePromises): Promise<[string[], number[]]>;
|
||||
function readdir(path: StringOrBuffer, encoding: unknown, withFileTypes: false, usePromises: typeof kUsePromises): Promise<string[]>;
|
||||
|
||||
function readFileUtf8(path: StringOrBuffer, flags: number): string;
|
||||
|
||||
function readlink(path: StringOrBuffer, encoding: unknown, req: FSReqCallback<string | Buffer>): void;
|
||||
function readlink(path: StringOrBuffer, encoding: unknown, req: undefined, ctx: FSSyncContext): string | Buffer;
|
||||
function readlink(path: StringOrBuffer, encoding: unknown, usePromises: typeof kUsePromises): Promise<string | Buffer>;
|
||||
@@ -273,6 +275,7 @@ export interface FsBinding {
|
||||
read: typeof InternalFSBinding.read;
|
||||
readBuffers: typeof InternalFSBinding.readBuffers;
|
||||
readdir: typeof InternalFSBinding.readdir;
|
||||
readFileUtf8: typeof InternalFSBinding.readFileUtf8;
|
||||
readlink: typeof InternalFSBinding.readlink;
|
||||
realpath: typeof InternalFSBinding.realpath;
|
||||
rename: typeof InternalFSBinding.rename;
|
||||
|
||||
Reference in new issue
Block a user