Skip to content

Commit 82119b3

Browse files
authored
Update index.d.ts
Support Typescript 4.4 (apache#500)
1 parent d25970e commit 82119b3

File tree

1 file changed

+62
-59
lines changed

1 file changed

+62
-59
lines changed

types/index.d.ts

Lines changed: 62 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//https://github.com/apache/cordova-plugin-file/pull/500
2+
13
// Type definitions for Apache Cordova File System plugin
24
// Project: https://github.com/apache/cordova-plugin-file
35
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
@@ -20,50 +22,51 @@ interface Window {
2022
successCallback: (fileSystem: FileSystem) => void,
2123
errorCallback?: (fileError: FileError) => void): void;
2224
/**
23-
* Look up file system Entry referred to by local URL.
25+
* Look up file system FileSystemEntry referred to by local URL.
2426
* @param string url URL referring to a local file or directory
25-
* @param successCallback invoked with Entry object corresponding to URL
27+
* @param successCallback invoked with FileSystemEntry object corresponding to URL
2628
* @param errorCallback invoked if error occurs retrieving file system entry
2729
*/
2830
resolveLocalFileSystemURL(url: string,
29-
successCallback: (entry: Entry) => void,
30-
errorCallback?: (error: FileError) => void): void;
31+
successCallback: (entry: FileSystemEntry) => void,
32+
errorCallback?: (error: FileError) => void): void;
3133
/**
32-
* Look up file system Entry referred to by local URI.
34+
* Look up file system FileSystemEntry referred to by local URI.
3335
* @param string uri URI referring to a local file or directory
34-
* @param successCallback invoked with Entry object corresponding to URI
36+
* @param successCallback invoked with FileSystemEntry object corresponding to URI
3537
* @param errorCallback invoked if error occurs retrieving file system entry
3638
*/
3739
resolveLocalFileSystemURI(uri: string,
38-
successCallback: (entry: Entry) => void,
39-
errorCallback?: (error: FileError) => void): void;
40+
successCallback: (entry: FileSystemEntry) => void,
41+
errorCallback?: (error: FileError) => void): void;
4042
TEMPORARY: number;
4143
PERSISTENT: number;
4244
}
4345

4446
/** This interface represents a file system. */
45-
interface FileSystem {
46-
/* The name of the file system, unique across the list of exposed file systems. */
47-
name: string;
48-
/** The root directory of the file system. */
49-
root: DirectoryEntry;
50-
}
47+
// Commented in order to avoid conflicts with lib.dom.d.ts
48+
// interface FileSystem {
49+
// /* The name of the file system, unique across the list of exposed file systems. */
50+
// name: string;
51+
// /** The root directory of the file system. */
52+
// root: FileSystemDirectoryEntry;
53+
// }
5154

5255
/**
5356
* An abstract interface representing entries in a file system,
54-
* each of which may be a File or DirectoryEntry.
57+
* each of which may be a File or FileSystemDirectoryEntry.
5558
*/
56-
interface Entry {
57-
/** Entry is a file. */
58-
isFile: boolean;
59-
/** Entry is a directory. */
60-
isDirectory: boolean;
59+
interface FileSystemEntry {
60+
/** FileSystemEntry is a file. */
61+
// isFile: boolean;
62+
/** FileSystemEntry is a directory. */
63+
// isDirectory: boolean;
6164
/** The name of the entry, excluding the path leading to it. */
62-
name: string;
65+
// name: string;
6366
/** The full absolute path from the root to the entry. */
64-
fullPath: string;
67+
// fullPath: string;
6568
/** The file system on which the entry resides. */
66-
filesystem: FileSystem;
69+
// filesystem: FileSystem;
6770
nativeURL: string;
6871
/**
6972
* Look up metadata about this entry.
@@ -82,14 +85,14 @@ interface Entry {
8285
* A move of a file on top of an existing file must attempt to delete and replace that file.
8386
* A move of a directory on top of an existing empty directory must attempt to delete and replace that directory.
8487
* @param parent The directory to which to move the entry.
85-
* @param newName The new name of the entry. Defaults to the Entry's current name if unspecified.
86-
* @param successCallback A callback that is called with the Entry for the new location.
88+
* @param newName The new name of the entry. Defaults to the FileSystemEntry's current name if unspecified.
89+
* @param successCallback A callback that is called with the FileSystemEntry for the new location.
8790
* @param errorCallback A callback that is called when errors happen.
8891
*/
89-
moveTo(parent: DirectoryEntry,
90-
newName?: string,
91-
successCallback?: (entry: Entry) => void,
92-
errorCallback?: (error: FileError) => void): void;
92+
moveTo(parent: FileSystemDirectoryEntry,
93+
newName?: string,
94+
successCallback?: (entry: FileSystemEntry) => void,
95+
errorCallback?: (error: FileError) => void): void;
9396
/**
9497
* Copy an entry to a different location on the file system. It is an error to try to:
9598
* copy a directory inside itself or to any child at any depth;
@@ -101,14 +104,14 @@ interface Entry {
101104
* A copy of a directory on top of an existing empty directory must attempt to delete and replace that directory.
102105
* Directory copies are always recursive--that is, they copy all contents of the directory.
103106
* @param parent The directory to which to move the entry.
104-
* @param newName The new name of the entry. Defaults to the Entry's current name if unspecified.
105-
* @param successCallback A callback that is called with the Entry for the new object.
107+
* @param newName The new name of the entry. Defaults to the FileSystemEntry's current name if unspecified.
108+
* @param successCallback A callback that is called with the FileSystemEntry for the new object.
106109
* @param errorCallback A callback that is called when errors happen.
107110
*/
108-
copyTo(parent: DirectoryEntry,
109-
newName?: string,
110-
successCallback?: (entry: Entry) => void,
111-
errorCallback?: (error: FileError) => void): void;
111+
copyTo(parent: FileSystemDirectoryEntry,
112+
newName?: string,
113+
successCallback?: (entry: FileSystemEntry) => void,
114+
errorCallback?: (error: FileError) => void): void;
112115
/**
113116
* Returns a URL that can be used as the src attribute of a <video> or <audio> tag.
114117
* If that is not possible, construct a cdvfile:// URL.
@@ -126,14 +129,14 @@ interface Entry {
126129
* @param errorCallback A callback that is called when errors happen.
127130
*/
128131
remove(successCallback: () => void,
129-
errorCallback?: (error: FileError) => void): void;
132+
errorCallback?: (error: FileError) => void): void;
130133
/**
131-
* Look up the parent DirectoryEntry containing this Entry. If this Entry is the root of its filesystem, its parent is itself.
134+
* Look up the parent FileSystemDirectoryEntry containing this FileSystemEntry. If this FileSystemEntry is the root of its filesystem, its parent is itself.
132135
* @param successCallback A callback that is called with the time of the last modification.
133136
* @param errorCallback A callback that is called when errors happen.
134137
*/
135-
getParent(successCallback: (entry: Entry) => void,
136-
errorCallback?: (error: FileError) => void): void;
138+
getParent(successCallback: (entry: FileSystemEntry) => void,
139+
errorCallback?: (error: FileError) => void): void;
137140
}
138141

139142
/** This interface supplies information about the state of a file or directory. */
@@ -145,43 +148,43 @@ interface Metadata {
145148
}
146149

147150
/** This interface represents a directory on a file system. */
148-
interface DirectoryEntry extends Entry {
151+
interface FileSystemDirectoryEntry extends FileSystemEntry {
149152
/**
150153
* Creates a new DirectoryReader to read Entries from this Directory.
151154
*/
152155
createReader(): DirectoryReader;
153156
/**
154157
* Creates or looks up a file.
155-
* @param path Either an absolute path or a relative path from this DirectoryEntry
158+
* @param path Either an absolute path or a relative path from this FileSystemDirectoryEntry
156159
* to the file to be looked up or created.
157160
* It is an error to attempt to create a file whose immediate parent does not yet exist.
158161
* @param options If create and exclusive are both true, and the path already exists, getFile must fail.
159-
* If create is true, the path doesn't exist, and no other error occurs, getFile must create it as a zero-length file and return a corresponding FileEntry.
162+
* If create is true, the path doesn't exist, and no other error occurs, getFile must create it as a zero-length file and return a corresponding FileSystemFileEntry.
160163
* If create is not true and the path doesn't exist, getFile must fail.
161164
* If create is not true and the path exists, but is a directory, getFile must fail.
162-
* Otherwise, if no other error occurs, getFile must return a FileEntry corresponding to path.
165+
* Otherwise, if no other error occurs, getFile must return a FileSystemFileEntry corresponding to path.
163166
* @param successCallback A callback that is called to return the File selected or created.
164167
* @param errorCallback A callback that is called when errors happen.
165168
*/
166169
getFile(path: string, options?: Flags,
167-
successCallback?: (entry: FileEntry) => void,
168-
errorCallback?: (error: FileError) => void): void;
170+
successCallback?: (entry: FileSystemFileEntry) => void,
171+
errorCallback?: (error: FileError) => void): void;
169172
/**
170173
* Creates or looks up a directory.
171-
* @param path Either an absolute path or a relative path from this DirectoryEntry
174+
* @param path Either an absolute path or a relative path from this FileSystemDirectoryEntry
172175
* to the directory to be looked up or created.
173176
* It is an error to attempt to create a directory whose immediate parent does not yet exist.
174177
* @param options If create and exclusive are both true and the path already exists, getDirectory must fail.
175-
* If create is true, the path doesn't exist, and no other error occurs, getDirectory must create and return a corresponding DirectoryEntry.
178+
* If create is true, the path doesn't exist, and no other error occurs, getDirectory must create and return a corresponding FileSystemDirectoryEntry.
176179
* If create is not true and the path doesn't exist, getDirectory must fail.
177180
* If create is not true and the path exists, but is a file, getDirectory must fail.
178-
* Otherwise, if no other error occurs, getDirectory must return a DirectoryEntry corresponding to path.
181+
* Otherwise, if no other error occurs, getDirectory must return a FileSystemDirectoryEntry corresponding to path.
179182
* @param successCallback A callback that is called to return the Directory selected or created.
180183
* @param errorCallback A callback that is called when errors happen.
181184
*/
182185
getDirectory(path: string, options?: Flags,
183-
successCallback?: (entry: DirectoryEntry) => void,
184-
errorCallback?: (error: FileError) => void): void;
186+
successCallback?: (entry: FileSystemDirectoryEntry) => void,
187+
errorCallback?: (error: FileError) => void): void;
185188
/**
186189
* Deletes a directory and all of its contents, if any. In the event of an error (e.g. trying
187190
* to delete a directory that contains a file that cannot be removed), some of the contents
@@ -190,7 +193,7 @@ interface DirectoryEntry extends Entry {
190193
* @param errorCallback A callback that is called when errors happen.
191194
*/
192195
removeRecursively(successCallback: () => void,
193-
errorCallback?: (error: FileError) => void): void;
196+
errorCallback?: (error: FileError) => void): void;
194197
}
195198

196199
/**
@@ -223,27 +226,27 @@ interface DirectoryReader {
223226
* @param errorCallback A callback indicating that there was an error reading from the Directory.
224227
*/
225228
readEntries(
226-
successCallback: (entries: Entry[]) => void,
229+
successCallback: (entries: FileSystemEntry[]) => void,
227230
errorCallback?: (error: FileError) => void): void;
228231
}
229232

230233
/** This interface represents a file on a file system. */
231-
interface FileEntry extends Entry {
234+
interface FileSystemFileEntry extends FileSystemEntry {
232235
/**
233-
* Creates a new FileWriter associated with the file that this FileEntry represents.
236+
* Creates a new FileWriter associated with the file that this FileSystemFileEntry represents.
234237
* @param successCallback A callback that is called with the new FileWriter.
235238
* @param errorCallback A callback that is called when errors happen.
236239
*/
237240
createWriter(successCallback: (
238-
writer: FileWriter) => void,
239-
errorCallback?: (error: FileError) => void): void;
241+
writer: FileWriter) => void,
242+
errorCallback?: (error: FileError) => void): void;
240243
/**
241-
* Returns a File that represents the current state of the file that this FileEntry represents.
244+
* Returns a File that represents the current state of the file that this FileSystemFileEntry represents.
242245
* @param successCallback A callback that is called with the File.
243246
* @param errorCallback A callback that is called when errors happen.
244247
*/
245248
file(successCallback: (file: File) => void,
246-
errorCallback?: (error: FileError) => void): void;
249+
errorCallback?: (error: FileError) => void): void;
247250
}
248251

249252
/**
@@ -375,4 +378,4 @@ interface Cordova {
375378
declare enum LocalFileSystem {
376379
PERSISTENT=1,
377380
TEMPORARY=0
378-
}
381+
}

0 commit comments

Comments
 (0)