fix: check file is file using instanceof instead of cast

This commit is contained in:
Jacobtread 2024-04-01 20:33:56 +13:00
parent c1fbc735e9
commit 33db60aa67

View file

@ -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);