11import { Platform , ModalPropsIOS } from 'react-native'
22import invariant from 'invariant'
3- import type { PlatformTypes , SupportedPlatforms } from './fileTypes'
3+ import type { PlatformTypes } from './fileTypes'
44import { perPlatformTypes } from './fileTypes'
55import { NativeDocumentPicker } from './NativeDocumentPicker'
66
@@ -21,19 +21,16 @@ export type DirectoryPickerResponse = {
2121
2222export type TransitionStyle = 'coverVertical' | 'flipHorizontal' | 'crossDissolve' | 'partialCurl'
2323
24- export type DocumentPickerOptions < OS extends SupportedPlatforms > = {
25- type ?:
26- | string
27- | PlatformTypes [ OS ] [ keyof PlatformTypes [ OS ] ]
28- | Array < PlatformTypes [ OS ] [ keyof PlatformTypes [ OS ] ] | string >
24+ export type DocumentPickerOptions = {
25+ type ?: string | Array < PlatformTypes | string >
2926 mode ?: 'import' | 'open'
3027 copyTo ?: 'cachesDirectory' | 'documentDirectory'
3128 allowMultiSelection ?: boolean
3229 transitionStyle ?: TransitionStyle
3330} & Pick < ModalPropsIOS , 'presentationStyle' >
3431
35- export async function pickDirectory < OS extends SupportedPlatforms > (
36- params ?: Pick < DocumentPickerOptions < OS > , 'presentationStyle' | 'transitionStyle' > ,
32+ export async function pickDirectory (
33+ params ?: Pick < DocumentPickerOptions , 'presentationStyle' | 'transitionStyle' > ,
3734) : Promise < DirectoryPickerResponse | null > {
3835 if ( Platform . OS === 'ios' ) {
3936 const result = await pick ( {
@@ -48,27 +45,23 @@ export async function pickDirectory<OS extends SupportedPlatforms>(
4845 }
4946}
5047
51- export function pickSingle < OS extends SupportedPlatforms > (
52- opts ?: DocumentPickerOptions < OS > ,
53- ) : Promise < DocumentPickerResponse > {
48+ export function pickSingle ( opts ?: DocumentPickerOptions ) : Promise < DocumentPickerResponse > {
5449 const options = {
5550 ...opts ,
5651 allowMultiSelection : false ,
5752 }
5853 return pick ( options ) . then ( ( results ) => results [ 0 ] )
5954}
6055
61- export function pick < OS extends SupportedPlatforms > (
62- opts ?: DocumentPickerOptions < OS > ,
63- ) : Promise < DocumentPickerResponse [ ] > {
56+ export function pick ( opts ?: DocumentPickerOptions ) : Promise < DocumentPickerResponse [ ] > {
6457 const options = {
6558 // must be false to maintain old (v5) behavior
6659 allowMultiSelection : false ,
6760 type : [ types . allFiles ] ,
6861 ...opts ,
6962 }
7063
71- const newOpts : DoPickParams < OS > = {
64+ const newOpts : DoPickParams = {
7265 presentationStyle : 'formSheet' ,
7366 transitionStyle : 'coverVertical' ,
7467 ...options ,
@@ -78,16 +71,14 @@ export function pick<OS extends SupportedPlatforms>(
7871 return doPick ( newOpts )
7972}
8073
81- type DoPickParams < OS extends SupportedPlatforms > = DocumentPickerOptions < OS > & {
82- type : Array < PlatformTypes [ OS ] [ keyof PlatformTypes [ OS ] ] | string >
74+ type DoPickParams = DocumentPickerOptions & {
75+ type : Array < PlatformTypes | string >
8376 allowMultiSelection : boolean
8477 presentationStyle : NonNullable < ModalPropsIOS [ 'presentationStyle' ] >
8578 transitionStyle : TransitionStyle
8679}
8780
88- function doPick < OS extends SupportedPlatforms > (
89- options : DoPickParams < OS > ,
90- ) : Promise < DocumentPickerResponse [ ] > {
81+ function doPick ( options : DoPickParams ) : Promise < DocumentPickerResponse [ ] > {
9182 invariant (
9283 ! ( 'filetype' in options ) ,
9384 'A `filetype` option was passed to DocumentPicker.pick, the correct option is `type`' ,
0 commit comments