Skip to content

Commit 2fb7cc9

Browse files
anonrigtargos
authored andcommitted
fs: fix typings
PR-URL: #53626 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 87167fa commit 2fb7cc9

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

lib/fs.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ function exists(path, callback) {
254254
validateFunction(callback, 'cb');
255255

256256
function suppressedCallback(err) {
257-
callback(err ? false : true);
257+
callback(!err);
258258
}
259259

260260
try {
@@ -759,8 +759,8 @@ function readSync(fd, buffer, offsetOrOptions, length, position) {
759759
* @param {(
760760
* err?: Error,
761761
* bytesRead?: number,
762-
* buffers?: ArrayBufferView[];
763-
* ) => any} callback
762+
* buffers?: ArrayBufferView[]
763+
* ) => any} callback
764764
* @returns {void}
765765
*/
766766
function readv(fd, buffers, position, callback) {
@@ -813,9 +813,9 @@ function readvSync(fd, buffers, position) {
813813
* @param {number | null} [position]
814814
* @param {(
815815
* err?: Error,
816-
* bytesWritten?: number;
816+
* bytesWritten?: number,
817817
* buffer?: Buffer | TypedArray | DataView
818-
* ) => any} callback
818+
* ) => any} callback
819819
* @returns {void}
820820
*/
821821
function write(fd, buffer, offsetOrOptions, length, position, callback) {
@@ -891,6 +891,8 @@ ObjectDefineProperty(write, kCustomPromisifyArgsSymbol,
891891
* length?: number;
892892
* position?: number | null;
893893
* }} [offsetOrOptions]
894+
* @param {number} [length]
895+
* @param {number} [position]
894896
* @returns {number}
895897
*/
896898
function writeSync(fd, buffer, offsetOrOptions, length, position) {
@@ -1084,14 +1086,11 @@ function truncateSync(path, len) {
10841086
}
10851087
// Allow error to be thrown, but still close fd.
10861088
const fd = fs.openSync(path, 'r+');
1087-
let ret;
1088-
10891089
try {
1090-
ret = fs.ftruncateSync(fd, len);
1090+
fs.ftruncateSync(fd, len);
10911091
} finally {
10921092
fs.closeSync(fd);
10931093
}
1094-
return ret;
10951094
}
10961095

10971096
/**
@@ -1450,8 +1449,8 @@ function readdirSyncRecursive(basePath, options) {
14501449
* }} [options]
14511450
* @param {(
14521451
* err?: Error,
1453-
* files?: string[] | Buffer[] | Dirent[];
1454-
* ) => any} callback
1452+
* files?: string[] | Buffer[] | Dirent[]
1453+
* ) => any} callback
14551454
* @returns {void}
14561455
*/
14571456
function readdir(path, options, callback) {
@@ -1957,13 +1956,11 @@ function lchmodSync(path, mode) {
19571956

19581957
// Prefer to return the chmod error, if one occurs,
19591958
// but still try to close, and report closing errors if they occur.
1960-
let ret;
19611959
try {
1962-
ret = fs.fchmodSync(fd, mode);
1960+
fs.fchmodSync(fd, mode);
19631961
} finally {
19641962
fs.closeSync(fd);
19651963
}
1966-
return ret;
19671964
}
19681965

19691966
/**
@@ -2838,7 +2835,7 @@ function realpath(p, options, callback) {
28382835

28392836
// On windows, check that the root exists. On unix there is no need.
28402837
if (isWindows && !knownHard.has(base)) {
2841-
fs.lstat(base, (err, stats) => {
2838+
fs.lstat(base, (err) => {
28422839
if (err) return callback(err);
28432840
knownHard.add(base);
28442841
LOOP();

typings/internalBinding/fs.d.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ declare namespace InternalFSBinding {
5757
}
5858

5959
function access(path: StringOrBuffer, mode: number, req: FSReqCallback): void;
60-
function access(path: StringOrBuffer, mode: number, req: undefined, ctx: FSSyncContext): void;
60+
function access(path: StringOrBuffer, mode: number): void;
6161
function access(path: StringOrBuffer, mode: number, usePromises: typeof kUsePromises): Promise<void>;
6262

6363
function chmod(path: string, mode: number, req: FSReqCallback): void;
@@ -70,7 +70,7 @@ declare namespace InternalFSBinding {
7070
function chown(path: string, uid: number, gid: number): void;
7171

7272
function close(fd: number, req: FSReqCallback): void;
73-
function close(fd: number, req: undefined, ctx: FSSyncContext): void;
73+
function close(fd: number): void;
7474

7575
function copyFile(src: StringOrBuffer, dest: StringOrBuffer, mode: number, req: FSReqCallback): void;
7676
function copyFile(src: StringOrBuffer, dest: StringOrBuffer, mode: number, req: undefined, ctx: FSSyncContext): void;
@@ -154,7 +154,7 @@ declare namespace InternalFSBinding {
154154
function mkdir(path: string, mode: number, recursive: false, usePromises: typeof kUsePromises): Promise<void>;
155155

156156
function open(path: StringOrBuffer, flags: number, mode: number, req: FSReqCallback<number>): void;
157-
function open(path: StringOrBuffer, flags: number, mode: number, req: undefined, ctx: FSSyncContext): number;
157+
function open(path: StringOrBuffer, flags: number, mode: number): number;
158158

159159
function openFileHandle(path: StringOrBuffer, flags: number, mode: number, usePromises: typeof kUsePromises): Promise<FileHandle>;
160160

@@ -176,6 +176,8 @@ declare namespace InternalFSBinding {
176176
function readdir(path: StringOrBuffer, encoding: unknown, withFileTypes: true, usePromises: typeof kUsePromises): Promise<[string[], number[]]>;
177177
function readdir(path: StringOrBuffer, encoding: unknown, withFileTypes: false, usePromises: typeof kUsePromises): Promise<string[]>;
178178

179+
function readFileUtf8(path: StringOrBuffer, flags: number): string;
180+
179181
function readlink(path: StringOrBuffer, encoding: unknown, req: FSReqCallback<string | Buffer>): void;
180182
function readlink(path: StringOrBuffer, encoding: unknown, req: undefined, ctx: FSSyncContext): string | Buffer;
181183
function readlink(path: StringOrBuffer, encoding: unknown, usePromises: typeof kUsePromises): Promise<string | Buffer>;
@@ -273,6 +275,7 @@ export interface FsBinding {
273275
read: typeof InternalFSBinding.read;
274276
readBuffers: typeof InternalFSBinding.readBuffers;
275277
readdir: typeof InternalFSBinding.readdir;
278+
readFileUtf8: typeof InternalFSBinding.readFileUtf8;
276279
readlink: typeof InternalFSBinding.readlink;
277280
realpath: typeof InternalFSBinding.realpath;
278281
rename: typeof InternalFSBinding.rename;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy