I don’t think your suggestion of just using MarkdownFileInfo is a good idea. From a pure types perspective it works, but MarkdownView | MarkdownFileInfo signals that MarkdownView is a common occurrence. With only MarkdownFileInfo, devs need a deep knowledge of the types to see that they could be getting a MarkdownView.
They can’t use all properties of MarkdownView anyways, because there is a chance they get an instance of MarkdownFileInfo which is NOT the MarkdownView, so knowledge of the fact it could be MarkdownView doesn’t give much.
Of course you can do something like
if (ctx instanceof MarkdownView) {
console.log(ctx.allowNoFile);
}
But you could do the same even if ctx was declared as MarkdownFileInfo.
While your justification makes sense, I don’t think it is consistent enough across all the API.
Why does API have TAbstractFile instead of TFile | TFolder?
Or inconsistency with frontmatter vs frontMatter in the API: e.g., frontmatter?: FrontMatterCache.