autofix array type definitions

This commit is contained in:
Abbey Campbell
2025-12-18 14:27:39 -08:00
parent 5fc34554c6
commit a84d2fb6d3
60 changed files with 110 additions and 110 deletions

View File

@@ -65,12 +65,12 @@ export interface ErrorWithResponse {
url: string;
json: () => Promise<{
status: string;
errors: Array<{
errors: {
errorCode: string;
message: string;
from: string | null;
stack: string | null;
}>;
}[];
}>;
};
status?: number;

View File

@@ -66,10 +66,10 @@ const fetchRemoteObservation = async (
};
const fetchRemoteObservations = async (
uuids: Array<string>,
uuids: string[],
params: Object = {},
opts: Object = {},
): Promise<?Array<Object>> => {
): Promise<?Object[]> => {
try {
const response = await inatjs.observations.fetch(
uuids,

View File

@@ -5,7 +5,7 @@ import inatjs from "inaturalistjs";
import handleError from "./error";
const fetchPlace = async (
id: number | Array<number>,
id: number | number[],
params: Object = {},
opts: Object = {},
): Promise<?Object> => {

View File

@@ -47,7 +47,7 @@ function mapToLocalSchema( taxon ) {
}
async function fetchTaxon(
id: number | Array<number>,
id: number | number[],
params: Object = {},
opts: Object = {},
): Promise<?Object> {

View File

@@ -71,7 +71,7 @@ const fetchRemoteUser = async (
};
const fetchUsers = async (
ids: Array<number>,
ids: number[],
params: Object = {},
opts: Object = {},
): Promise<?Object> => {

View File

@@ -21,7 +21,7 @@ const logger = log.extend( "App" );
type SharedItem = {
mimeType: string,
data: string | Array<string>
data: string | string[]
};
const handleShare = ( navigation, item: ?SharedItem ) => {

View File

@@ -21,7 +21,7 @@ interface Props {
takingPhoto: boolean;
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
takePhotoAndStoreUri: Function;
newPhotoUris: Array<object>;
newPhotoUris: object[];
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
setNewPhotoUris: Function;
takePhotoOptions: object;

View File

@@ -53,7 +53,7 @@ type Props = {
takingPhoto: boolean,
takePhotoAndStoreUri: Function,
takePhotoOptions: Object,
newPhotoUris: Array<Object>,
newPhotoUris: Object[],
setNewPhotoUris: Function
};

View File

@@ -11,7 +11,7 @@ import { useTranslation } from "sharedHooks";
type Props = {
canFetch?: boolean,
contentContainerStyle?: Object,
data: Array<Object>,
data: Object[],
fetchNextPage: boolean,
hideLoadingWheel: boolean,
isFetchingNextPage: boolean,

View File

@@ -57,7 +57,7 @@ type FullPageWebViewParams = {
title?: string;
loggedIn?: boolean;
skipSetSourceInShouldStartLoadWithRequest?: boolean;
clickablePathnames?: Array<string>;
clickablePathnames?: string[];
shouldLoadUrl?: ( url: string ) => boolean;
}

View File

@@ -31,16 +31,16 @@ type Props = {
onDeletePhoto?: Function,
onClose?: Function,
onDeleteSound?: Function,
photos: Array<{
photos: {
id?: number,
url: string,
localFilePath?: string,
attribution?: string,
licenseCode?: string
}>,
sounds?: Array<{
}[],
sounds?: {
file_url: string
}>,
}[],
selectedMediaIndex: number,
setSelectedMediaIndex: Function
}

View File

@@ -13,18 +13,18 @@ import useTranslation from "sharedHooks/useTranslation";
type Props = {
isLargeScreen?: boolean,
photos: Array<{
photos: {
id?: number,
url: string,
localFilePath?: string,
attribution?: string,
licenseCode?: string
}>,
}[],
scrollToIndex: Function,
selectedMediaIndex?: number,
sounds?: Array<{
sounds?: {
file_url: string
}>,
}[],
}
const SMALL_ITEM_CLASS = "rounded-sm w-[42px] h-[42px] mx-[6px] my-[12px]";

View File

@@ -30,16 +30,16 @@ type Props = {
onClose?: Function,
onDeletePhoto?: Function,
onDeleteSound?: Function,
photos?: Array<{
photos?: {
id?: number,
url: string,
localFilePath?: string,
attribution?: string,
licenseCode?: string
}>,
sounds?: Array<{
}[],
sounds?: {
file_url: string
}>,
}[],
uri?: string | null
}

View File

@@ -14,16 +14,16 @@ type Props = {
onClose?: Function,
onDeletePhoto?: Function,
onDeleteSound?: Function,
photos?: Array<{
photos?: {
id?: number,
url: string,
localFilePath?: string,
attribution?: string,
licenseCode?: string
}>,
sounds?: Array<{
}[],
sounds?: {
file_url: string
}>,
}[],
showModal: boolean,
uri?: string | null
}

View File

@@ -253,7 +253,7 @@ const MyObservationsContainer = ( ): React.FC => {
const [activeTab, setActiveTab] = useState( OBSERVATIONS_TAB );
let numTotalTaxaLocal: number | undefined;
const localObservedSpeciesCount: Array<SpeciesCount> = [];
const localObservedSpeciesCount: SpeciesCount[] = [];
if ( !currentUser ) {
// Calculate obs and leaf taxa counts from local observations
const distinctTaxonObs = realm.objects<RealmObservation>( "Observation" )

View File

@@ -11,7 +11,7 @@ import ActivityItem from "./ActivityItem";
type Props = {
observation:Object,
refetchRemoteObservation: Function,
activityItems: Array<Object>,
activityItems: Object[],
openAgreeWithIdSheet: Function,
isConnected: boolean,
targetItemID: number,

View File

@@ -14,12 +14,12 @@ const sectionClass = "mx-[15px] mb-[20px]";
// TODO: can we get a centralized type/interface for our realm objects, here observation and project
interface Props {
observation: {
project_observations: Array<{
project_observations: {
project: object;
}>;
non_traditional_projects: Array<{
}[];
non_traditional_projects: {
project: object;
}>;
}[];
};
}

View File

@@ -31,7 +31,7 @@ import SuggestIDSheet from "./Sheets/SuggestIDSheet";
const isTablet = DeviceInfo.isTablet();
type Props = {
activityItems: Array<Object>,
activityItems: Object[],
addingActivityItem: Function,
closeAgreeWithIdSheet: Function,
belongsToCurrentUser: boolean,
@@ -63,7 +63,7 @@ type Props = {
showSuggestIdSheet: boolean,
subscriptions?: Object,
suggestIdSheetDiscardChanges: Function,
tabs: Array<Object>,
tabs: Object[],
identBodySheetShown?: boolean,
onCloseIdentBodySheet?: Function,
newIdentification?: null | {

View File

@@ -12,16 +12,16 @@ import SoundContainer from "./SoundContainer";
type Props = {
loading: boolean,
photos: Array<{
photos: {
id?: number,
url: string,
localFilePath?: string,
attribution?: string,
licenseCode?: string
}>,
sounds?: Array<{
}[],
sounds?: {
file_url: string
}>,
}[],
tablet: boolean
}

View File

@@ -16,8 +16,8 @@ import ObsMedia from "./ObsMedia";
type Props = {
loading: boolean,
photos: Array<Object>,
sounds: Array<Object>,
photos: Object[],
sounds: Object[],
tablet: boolean
}

View File

@@ -11,7 +11,7 @@ import ActivityItem from "./ActivityItem";
type Props = {
observation:Object,
refetchRemoteObservation: Function,
activityItems: Array<Object>,
activityItems: Object[],
openAgreeWithIdSheet: Function,
isConnected: boolean,
targetItemID: ?number,

View File

@@ -6,12 +6,12 @@ import React, { useMemo } from "react";
// TODO: can we get a centralized type/interface for our realm objects, here observation and project
interface Props {
observation: {
project_observations: Array<{
project_observations: {
project: object;
}>;
non_traditional_projects: Array<{
}[];
non_traditional_projects: {
project: object;
}>;
}[];
};
}

View File

@@ -27,7 +27,7 @@ import StatusSection from "./StatusSection/StatusSection";
const cardClassBottom = "rounded-b-2xl border-lightGray border-[2px] pb-3 border-t-0 -mt-0.5 mb-4";
type Props = {
activityItems: Array<object>;
activityItems: object[];
addingActivityItem: boolean;
belongsToCurrentUser: boolean;
currentUser: RealmUser;

View File

@@ -11,16 +11,16 @@ import SoundContainer from "./SoundContainer";
type Props = {
loading: boolean,
photos: Array<{
photos: {
id?: number,
url: string,
localFilePath?: string,
attribution?: string,
licenseCode?: string
}>,
sounds?: Array<{
}[],
sounds?: {
file_url: string
}>
}[]
}
const ObsMedia = ( {

View File

@@ -16,8 +16,8 @@ import ObsMedia from "./ObsMedia";
type Props = {
loading: boolean,
photos: Array<Object>,
sounds: Array<Object>
photos: Object[],
sounds: Object[]
}
const ObsMediaDisplay = ( {

View File

@@ -22,7 +22,7 @@ const { useRealm } = RealmContext;
type Props = {
passesEvidenceTest: boolean;
observations: Array<object>;
observations: object[];
currentObservation: RealmObservation;
currentObservationIndex: number;
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type

View File

@@ -27,13 +27,13 @@ const logger = log.extend( "EvidenceList" );
type Props = {
handleAddEvidence?: Function,
observationSounds?: Array<{
observationSounds?: {
id?: number,
sound: {
file_url: string,
},
uuid: string
}>
}[]
}
const EvidenceList = ( {

View File

@@ -20,18 +20,18 @@ import AddEvidenceSheet from "./Sheets/AddEvidenceSheet";
type Props = {
currentObservation: Object,
isFetchingLocation: boolean,
locationTextClassNames: Array<string>,
locationTextClassNames: string[],
passesEvidenceTest: Function,
observationPhotos: Array<Object>,
observationPhotos: Object[],
setShowAddEvidenceSheet: Function,
showAddEvidenceSheet: boolean,
observationSounds?: Array<{
observationSounds?: {
id?: number,
sound: {
file_url: string,
},
uuid: string
}>,
}[],
onLocationPress: ( ) => void,
updateObservationKeys: Function
}

View File

@@ -10,7 +10,7 @@ import { useTranslation } from "sharedHooks";
type Props = {
currentObservationIndex: number,
setCurrentObservationIndex: Function,
observations: Array<Object>,
observations: Object[],
setResetScreen: Function,
transitionAnimation: Function,
transitionAnimationRef: Object

View File

@@ -21,7 +21,7 @@ import DiscardObservationSheet from "./Sheets/DiscardObservationSheet";
const { useRealm } = RealmContext;
type Props = {
observations: Array<Object>,
observations: Object[],
currentObservation: Object
}

View File

@@ -15,7 +15,7 @@ const { useRealm } = RealmContext;
type Props = {
currentObservation: Object,
onPressClose: Function,
observations: Array<Object>,
observations: Object[],
onDelete?: Function,
updateObservations: Function
}

View File

@@ -15,7 +15,7 @@ const { useRealm } = RealmContext;
type Props = {
onPressClose: Function,
discardObservation: Function,
observations: Array<Object>,
observations: Object[],
onSave?: Function
}

View File

@@ -35,7 +35,7 @@ const AnimatedFlashList = Animated.createAnimatedComponent( CustomFlashList );
type Props = {
contentContainerStyle?: Object,
data: Array<Object>,
data: Object[],
dataCanBeFetched?: boolean,
fetchFromLastObservation?: Function,
explore: boolean,

View File

@@ -7,7 +7,7 @@ import React from "react";
type Props = {
item: Object,
selectedObservations: Array<Object>,
selectedObservations: Object[],
selectObservationPhotos: Function,
style?: Object
}

View File

@@ -23,11 +23,11 @@ import GroupPhotoImage from "./GroupPhotoImage";
type Props = {
combinePhotos: Function,
groupedPhotos: Array<Object>,
groupedPhotos: Object[],
isCreatingObservations?: boolean,
navBasedOnUserSettings: Function,
removePhotos: Function,
selectedObservations: Array<Object>,
selectedObservations: Object[],
selectObservationPhotos: Function,
separatePhotos: Function,
totalPhotos: number

View File

@@ -2,7 +2,7 @@
const sortByTime = array => array.sort( ( a, b ) => b.timestamp - a.timestamp );
const flattenAndOrderSelectedPhotos = ( selectedObservations: ?Array<Object> ): Array<Object> => {
const flattenAndOrderSelectedPhotos = ( selectedObservations: ?Object[] ): Object[] => {
// combine selected observations into a single array
let combinedPhotos = [];
selectedObservations?.forEach( obs => {

View File

@@ -12,7 +12,7 @@ import {
import ProjectListItem from "./ProjectListItem";
interface Props {
projects: Array<object>;
projects: object[];
ListEmptyComponent?: React.JSX.Element;
ListFooterComponent?: React.JSX.Element;
onEndReached?: ( ) => void;

View File

@@ -12,10 +12,10 @@ import changeLanguage from "sharedHelpers/changeLanguage";
import { useTranslation } from "sharedHooks";
import { zustandStorage } from "stores/useStore";
type LocalesResponse = Array<{
type LocalesResponse = {
locale: string;
language_in_locale: string;
}>;
}[];
type Props = {
onChange: ( newLocale: string ) => void;

View File

@@ -23,7 +23,7 @@ interface Props extends PropsWithChildren {
containerClass?: string;
onLayout?: () => void;
sticky?: boolean;
buttonConfiguration?: Array<ButtonConfiguration>;
buttonConfiguration?: ButtonConfiguration[];
}
// Ensure this component is placed outside of scroll views

View File

@@ -36,7 +36,7 @@ interface Props {
// Callback when the user presses the close button or backdrop, not whenever the sheet
// closes
onPressClose?: ( ) => void;
snapPoints?: Array<string>;
snapPoints?: string[];
insideModal?: boolean;
keyboardShouldPersistTaps?: string;
testID?: string;

View File

@@ -4,7 +4,7 @@ import { View } from "components/styledComponents";
import React from "react";
type Props = {
iconClasses: Array<string>;
iconClasses: string[];
completeColor: string;
}

View File

@@ -8,7 +8,7 @@ import { useTranslation } from "sharedHooks";
type Props = {
color: string;
progress: number;
iconClasses: Array<string>;
iconClasses: string[];
uniqueKey?: string;
}

View File

@@ -27,7 +27,7 @@ type Props = {
shouldUseEvidenceLocation: boolean,
onPressPhoto: Function,
onTaxonChosen: Function,
photoUris: Array<string>,
photoUris: string[],
reloadSuggestions: Function,
selectedPhotoUri: string,
showImproveWithLocationButton: boolean,

View File

@@ -40,7 +40,7 @@ type Props = {
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
hideLocationToggleButton: Function;
hideSkip?: boolean;
observers: Array<string>;
observers: string[];
shouldUseEvidenceLocation: boolean;
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
toggleLocation: Function;

View File

@@ -13,7 +13,7 @@ const params = {
},
};
const useObservers = ( taxonIds: Array<number> ): Array<string> => {
const useObservers = ( taxonIds: number[] ): string[] => {
const { data } = useAuthenticatedQuery(
["fetchObservers", taxonIds],
( ) => fetchObservers( {

View File

@@ -20,13 +20,13 @@ import Photo from "realmModels/Photo";
type Props = {
loading: boolean,
onChangeIndex?: Function,
photos: Array<{
photos: {
id?: number,
url: string,
localFilePath?: string,
attribution?: string,
licenseCode?: string
}>,
}[],
tablet: boolean
}

View File

@@ -18,7 +18,7 @@ interface Props {
ListFooterComponent?: React.JSX.Element;
onEndReached?: ( ) => void;
refreshing?: boolean;
users: Array<object>;
users: object[];
onPress?: ( ) => void;
accessibilityLabel?: string;
keyboardShouldPersistTaps?: string;

View File

@@ -16,7 +16,7 @@ const DROP_SHADOW = getShadow( {
} );
type Props = {
tabs: Array<Object>,
tabs: Object[],
};
/* eslint-disable react/jsx-props-no-spreading */

View File

@@ -161,10 +161,10 @@ interface PLACE {
id: number;
place_type: number;
point_geojson: {
coordinates: Array<number>;
coordinates: number[];
};
bounding_box_geojson?: {
coordinates: Array<number>;
coordinates: number[];
};
type: string;
}

View File

@@ -106,18 +106,18 @@ export interface RealmObservationPojo {
_created_at?: Date;
_synced_at?: Date;
captive_flag: boolean | null;
comments: Array<RealmComment>;
comments: RealmComment[];
comments_viewed?: boolean;
description: string | null;
geoprivacy: string | null;
identifications: Array<RealmIdentification>;
identifications: RealmIdentification[];
identifications_viewed?: boolean;
latitude: number | null;
license_code: License | null;
longitude: number | null;
obscured?: boolean;
observationPhotos: Array<RealmObservationPhotoPojo>;
observationSounds: Array<RealmObservationSoundPojo>;
observationPhotos: RealmObservationPhotoPojo[];
observationSounds: RealmObservationSoundPojo[];
observed_on?: string;
observed_on_string: string | null;
observed_time_zone?: string;
@@ -139,8 +139,8 @@ export interface RealmObservationPojo {
export interface RealmObservation extends RealmObservationPojo {
missingBasics: ( ) => boolean;
needsSync: ( ) => boolean;
observationPhotos: Array<RealmObservationPhoto>;
observationSounds: Array<RealmObservationSound>;
observationPhotos: RealmObservationPhoto[];
observationSounds: RealmObservationSound[];
unviewed: ( ) => boolean;
updateNeedsSync: ( ) => boolean;
viewed: ( ) => boolean;

View File

@@ -5,24 +5,24 @@ class FlashListPerformanceTracker {
private itemsVisibleDuration: number;
private scrollEvents: Array<{
private scrollEvents: {
startTime: number;
endTime: number;
duration: number;
itemsFetched: number;
scrollDistance: number;
}> = [];
}[] = [];
private currentScrollEvent: unknown = null;
private fetchStartTime: number;
private fetchEvents: Array<{
private fetchEvents: {
startTime: number;
endTime: number;
duration: number;
itemsCount: number;
}> = [];
}[] = [];
private persistentMetrics = {
lastFetchTime: null as number | null,

View File

@@ -63,11 +63,11 @@ export const formatExifDateAsString = ( datetime: string ): string => {
// Parse the EXIF of all photos - fill out details (lat/lng/date) from all of these,
// in case the first photo is missing EXIF
export const readExifFromMultiplePhotos = async ( photoUris: Array<string> ): Promise<Object> => {
export const readExifFromMultiplePhotos = async ( photoUris: string[] ): Promise<Object> => {
const unifiedExif = {};
const responses = await Promise.allSettled( photoUris.map( parseExif ) );
const allExifPhotos: Array<{
const allExifPhotos: {
latitude: number,
longitude: number,
positional_accuracy: number,
@@ -75,7 +75,7 @@ export const readExifFromMultiplePhotos = async ( photoUris: Array<string> ): Pr
// Flow will complain that value is undefined, but the filter call ensures
// that it isn't
// $FlowIgnore
}> = responses.filter( r => r.value ).map( r => r.value );
}[] = responses.filter( r => r.value ).map( r => r.value );
allExifPhotos.filter( x => x ).forEach(
currentPhotoExif => {

View File

@@ -8,7 +8,7 @@ import { useCurrentUser } from "sharedHooks";
// Should work like React Query's useInfiniteQuery with our custom reactQueryRetry
// and authentication
const useAuthenticatedInfiniteQuery = (
queryKey: Array<string>,
queryKey: string[],
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
queryFunction: Function,
queryOptions: object = {},

View File

@@ -5,7 +5,7 @@ const useInfiniteUserScroll = (
queryKey: string,
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
apiCall: Function,
ids: Array<object>,
ids: object[],
newInputParams: object,
options: {
enabled: boolean;

View File

@@ -4,7 +4,7 @@ import { handleRetryDelay, reactQueryRetry } from "sharedHelpers/logging";
// Should work like React Query's useQuery with our custom reactQueryRetry
const useNonAuthenticatedQuery = (
queryKey: Array<string>,
queryKey: string[],
queryFunction: QueryFunction,
queryOptions: object = {},
) => useQuery( {

View File

@@ -16,7 +16,7 @@ interface SyncObservationsSlice {
autoSyncAbortController: AbortController | null;
currentDeleteCount: number;
deleteError: string | null;
deleteQueue: Array<string>;
deleteQueue: string[];
deletionsCompletedAt: Date | null;
initialNumDeletionsInQueue: number;
syncingStatus: SyncingStatus;

View File

@@ -30,8 +30,8 @@ interface UploadObservationsSlice {
numUploadsAttempted: number;
totalToolbarIncrements: number;
totalToolbarProgress: number;
totalUploadProgress: Array<TotalUploadProgress>;
uploadQueue: Array<string>;
totalUploadProgress: TotalUploadProgress[];
uploadQueue: string[];
uploadStatus: UploadStatus;
}

View File

@@ -22,9 +22,9 @@ interface MediaApiResponse {
page: number;
per_page: number;
total_results: number;
results: Array<{
results: {
id: number;
}>;
}[];
}
interface MappedObservationPhotoForUpdating {

View File

@@ -38,10 +38,10 @@ interface ObservationApiResponse {
page: number;
per_page: number;
total_results: number;
results: Array<{
results: {
uuid: string;
id: number;
}>;
}[];
}
async function validateAndGetToken( ): Promise<string> {

View File

@@ -84,7 +84,7 @@ const markRecordUploaded = (
recordUUID: string | null,
type: string,
response: {
results: Array<{id: number}>;
results: {id: number}[];
},
realm: object,
options?: {