diff --git a/src/volume.ts b/src/volume.ts index 59513fdb..667e3d88 100644 --- a/src/volume.ts +++ b/src/volume.ts @@ -1754,9 +1754,11 @@ export class Volume { truncate(id: TFileId, callback: TCallback); truncate(id: TFileId, len: number, callback: TCallback); truncate(id: TFileId, a: TCallback | number, b?: TCallback) { - if (isFd(id)) return this.ftruncate(id as number, a as any, b); + const len: number = typeof a === 'number' ? a : 0; + const callback: TCallback = validateCallback(typeof a === 'number' ? b : a); + + if (isFd(id)) return this.ftruncate(id as number, len, callback); - const [len, callback] = getArgAndCb(a, b, 0); this.wrapAsync(this.truncateBase, [id, len], callback); }