mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 19:51:53 +00:00
[atom] Clean up FilesystemChangeEvent (#24968)
Add a type for a single FilesystemChange, have `oldPath` on rename events only.
This commit is contained in:
committed by
Mohamed Hegazy
parent
54968ba726
commit
3b587e9ce3
@@ -3310,7 +3310,7 @@ const pathWatcherPromise = Atom.watchPath("/var/test", {}, (events) => {
|
||||
for (const event of events) {
|
||||
str = event.path;
|
||||
str = event.action;
|
||||
if (event.oldPath) str = event.oldPath;
|
||||
if (event.action === "renamed") str = event.oldPath;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Vendored
+13
-4
@@ -5647,19 +5647,28 @@ export interface FileSavedEvent {
|
||||
path: string;
|
||||
}
|
||||
|
||||
export type FilesystemChangeEvent = Array<{
|
||||
export interface FilesystemChangeBasic<
|
||||
Action extends "created"|"modified"|"deleted"|"renamed"
|
||||
= "created"|"modified"|"deleted"
|
||||
> {
|
||||
/** A string describing the filesystem action that occurred. */
|
||||
action: "created"|"modified"|"deleted"|"renamed";
|
||||
action: Action;
|
||||
|
||||
/** The absolute path to the filesystem entry that was acted upon. */
|
||||
path: string;
|
||||
}
|
||||
|
||||
export interface FilesystemChangeRename extends FilesystemChangeBasic<"renamed"> {
|
||||
/**
|
||||
* For rename events, a string containing the filesystem entry's former
|
||||
* absolute path.
|
||||
*/
|
||||
oldPath?: string;
|
||||
}>;
|
||||
oldPath: string;
|
||||
}
|
||||
|
||||
export type FilesystemChange = FilesystemChangeBasic|FilesystemChangeRename;
|
||||
|
||||
export type FilesystemChangeEvent = FilesystemChange[];
|
||||
|
||||
export interface FullKeybindingMatchEvent {
|
||||
/** The string of keystrokes that matched the binding. */
|
||||
|
||||
Reference in New Issue
Block a user