From 2ba6e0f8883dabeb1f31684f4f6743cbd3eb3d39 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sun, 7 Jul 2019 09:54:15 +1200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20refactor=20`#write`=20to?= =?UTF-8?q?=20be=20compatible=20w/=20`strictNullChecks`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/volume.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/volume.ts b/src/volume.ts index bedd9417..11ea97a7 100644 --- a/src/volume.ts +++ b/src/volume.ts @@ -1150,10 +1150,10 @@ export class Volume { validateFd(fd); let offset: number; - let length: number; + let length: number | undefined; let position: number; - let encoding: TEncoding; - let callback: (...args) => void; + let encoding: TEncoding | undefined; + let callback: ((...args) => void) | undefined; const tipa = typeof a; const tipb = typeof b; @@ -1198,18 +1198,18 @@ export class Volume { length = buf.length; } - validateCallback(callback); + const cb = validateCallback(callback); setImmediate(() => { try { const bytes = this.writeBase(fd, buf, offset, length, position); if (tipa !== 'string') { - callback(null, bytes, buf); + cb(null, bytes, buf); } else { - callback(null, bytes, a); + cb(null, bytes, a); } } catch (err) { - callback(err); + cb(err); } }); }