[Bug] `Vault.copy()` incomplete definition

Vault.copy() according to the docs

has the following signature.

copy(file: TFile, newPath: string): Promise<TFile>

However, based on its implementation and internal usage, it seems it also works for TFolder.

For example, Make a copy context menu action calls the same function for both files and folders.

I suggest the definition could be

copy(file: TFile, newPath: string): Promise<TFile>
copy(file: TFolder, newPath: string): Promise<TFolder>
copy(file: TAbstractFile, newPath: string): Promise<TAbstractFile>

// or
copy<T extends TAbstractFile>(file: T, newPath: string): Promise<T>

A little context in case it helps:
This was reported here on Discord.

Not a bug, this was just changed in 1.8, and we haven’t released the new API definition yet.

2 Likes