From 33db60aa67cd9a097e321df4d878224191f584b2 Mon Sep 17 00:00:00 2001 From: Jacobtread Date: Mon, 1 Apr 2024 20:33:56 +1300 Subject: [PATCH] fix: check file is file using instanceof instead of cast --- src/main.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main.ts b/src/main.ts index da201cb..b2435ce 100644 --- a/src/main.ts +++ b/src/main.ts @@ -128,12 +128,10 @@ class TimekeepComponent extends MarkdownRenderChild { // Ensure we actually have a section to write to if (sectionInfo === null) return; - const file = this.vault.getAbstractFileByPath( - this.context.sourcePath - ) as TFile | null; + const file = this.vault.getAbstractFileByPath(this.context.sourcePath); // Ensure the file still exists - if (file === null) return; + if (file === null || !(file instanceof TFile)) return; try { const content = await this.vault.read(file);