Skip to content

Commit

Permalink
[file-system] Fix getContentUriAsync return type
Browse files Browse the repository at this point in the history
  • Loading branch information
lukmccall committed Feb 26, 2020
1 parent 99b3c6c commit fa241ad
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 8 deletions.
6 changes: 3 additions & 3 deletions packages/expo-file-system/build/FileSystem.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/expo-file-system/build/FileSystem.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/expo-file-system/build/FileSystem.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions packages/expo-file-system/build/FileSystem.types.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/expo-file-system/build/FileSystem.types.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions packages/expo-file-system/src/FileSystem.ts
Expand Up @@ -14,6 +14,7 @@ import {
ReadingOptions,
WritingOptions,
ProgressEvent,
FileSystemContentUri,
} from './FileSystem.types';

if (!ExponentFileSystem) {
Expand All @@ -35,6 +36,7 @@ export {
ReadingOptions,
WritingOptions,
ProgressEvent,
FileSystemContentUri,
};

function normalizeEndingSlash(p: string | null): string | null {
Expand Down Expand Up @@ -69,15 +71,15 @@ export async function readAsStringAsync(
return await ExponentFileSystem.readAsStringAsync(fileUri, options || {});
}

export async function getContentUriAsync(fileUri: string): Promise<string> {
export async function getContentUriAsync(fileUri: string): Promise<FileSystemContentUri> {
if (Platform.OS === 'android') {
if (!ExponentFileSystem.getContentUriAsync) {
throw new UnavailabilityError('expo-file-system', 'getContentUriAsync');
}
return await ExponentFileSystem.getContentUriAsync(fileUri);
} else {
return new Promise(function(resolve, reject) {
resolve(fileUri);
resolve({ uri: fileUri });
});
}
}
Expand Down
4 changes: 4 additions & 0 deletions packages/expo-file-system/src/FileSystem.types.ts
Expand Up @@ -66,6 +66,10 @@ export type ProgressEvent = {
};
};

export type FileSystemContentUri = {
uri: string;
};

type PlatformMethod = (...args: any[]) => Promise<any>;

export interface ExponentFileSystemModule {
Expand Down

0 comments on commit fa241ad

Please sign in to comment.