From 1c4a4ba78e99d3250b1e6f25952408e21b9cacfc Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sun, 7 Jul 2019 00:00:35 +1200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20refactor=20`#openFile`=20?= =?UTF-8?q?to=20be=20compatible=20w/=20`strictNullChecks`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/volume.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/volume.ts b/src/volume.ts index 88259204..70bc3221 100644 --- a/src/volume.ts +++ b/src/volume.ts @@ -923,14 +923,19 @@ export class Volume { return file; } - private openFile(filename: string, flagsNum: number, modeNum: number, resolveSymlinks: boolean = true): File { + private openFile( + filename: string, + flagsNum: number, + modeNum: number | undefined, + resolveSymlinks: boolean = true, + ): File { const steps = filenameToSteps(filename); - let link: Link = resolveSymlinks ? this.getResolvedLink(steps) : this.getLink(steps); + let link: Link | null = resolveSymlinks ? this.getResolvedLink(steps) : this.getLink(steps); // Try creating a new file, if it does not exist. if (!link && flagsNum & O_CREAT) { // const dirLink: Link = this.getLinkParent(steps); - const dirLink: Link = this.getResolvedLink(steps.slice(0, steps.length - 1)); + const dirLink: Link | null = this.getResolvedLink(steps.slice(0, steps.length - 1)); // if(!dirLink) throw createError(ENOENT, 'open', filename); if (!dirLink) throw createError(ENOENT, 'open', sep + steps.join(sep));