mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[atom] add type guarding to isFile() and isDirectory() methods (#22591)
This commit is contained in:
parent
28cf53f162
commit
12522af29a
@ -32,6 +32,7 @@ declare let editor: Atom.TextEditor;
|
||||
declare let editors: Atom.TextEditor[];
|
||||
declare let emitter: Atom.Emitter;
|
||||
declare let file: Atom.File;
|
||||
declare let fileOrDir: Atom.File | Atom.Directory;
|
||||
declare let grammar: Atom.Grammar;
|
||||
declare let grammars: Atom.Grammar[];
|
||||
declare let gutter: Atom.Gutter;
|
||||
@ -966,6 +967,16 @@ function testFile() {
|
||||
file.writeSync("Test");
|
||||
}
|
||||
|
||||
// File/Directory Type Guarding ===============================================
|
||||
function testFileDirectoryTypeGuarding() {
|
||||
if (fileOrDir.isFile()) {
|
||||
file = fileOrDir;
|
||||
}
|
||||
if (fileOrDir.isDirectory()) {
|
||||
dir = fileOrDir;
|
||||
}
|
||||
}
|
||||
|
||||
// GitRepository ==============================================================
|
||||
function testGitRepository() {
|
||||
// Construction and Destruction
|
||||
|
||||
8
types/atom/index.d.ts
vendored
8
types/atom/index.d.ts
vendored
@ -3279,10 +3279,10 @@ export class Directory {
|
||||
|
||||
// Directory Metadata
|
||||
/** Returns a boolean, always false. */
|
||||
isFile(): boolean;
|
||||
isFile(): this is File;
|
||||
|
||||
/** Returns a roolean, always true. */
|
||||
isDirectory(): boolean;
|
||||
isDirectory(): this is Directory;
|
||||
|
||||
/** Returns a boolean indicating whether or not this is a symbolic link. */
|
||||
isSymbolicLink(): boolean;
|
||||
@ -3496,10 +3496,10 @@ export class File {
|
||||
|
||||
// File Metadata
|
||||
/** Returns a boolean, always true. */
|
||||
isFile(): boolean;
|
||||
isFile(): this is File;
|
||||
|
||||
/** Returns a boolean, always false. */
|
||||
isDirectory(): boolean;
|
||||
isDirectory(): this is Directory;
|
||||
|
||||
/** Returns a boolean indicating whether or not this is a symbolic link. */
|
||||
isSymbolicLink(): boolean;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user