diff --git a/packages/pl-fe/src/actions/about.ts b/packages/pl-fe/src/actions/about.ts index ceb17ad29..abc74c13b 100644 --- a/packages/pl-fe/src/actions/about.ts +++ b/packages/pl-fe/src/actions/about.ts @@ -23,7 +23,7 @@ interface FetchAboutPageFailAction { type: typeof FETCH_ABOUT_PAGE_FAIL; slug: string; locale?: string; - error: any; + error: unknown; } const fetchAboutPage = (slug = 'index', locale?: string) => (dispatch: AppDispatch, getState: () => RootState) => { diff --git a/packages/pl-fe/src/actions/auth.ts b/packages/pl-fe/src/actions/auth.ts index 4c34b7fa7..49d5f7286 100644 --- a/packages/pl-fe/src/actions/auth.ts +++ b/packages/pl-fe/src/actions/auth.ts @@ -174,7 +174,7 @@ interface VerifyCredentialsSuccessAction { interface VerifyCredentialsFailAction { type: typeof VERIFY_CREDENTIALS_FAIL; token: string; - error: any; + error: unknown; } const verifyCredentials = (token: string, accountUrl?: string) => @@ -220,7 +220,7 @@ interface AuthAccountRememberSuccessAction { interface AuthAccountRememberFailAction { type: typeof AUTH_ACCOUNT_REMEMBER_FAIL; - error: any; + error: unknown; accountUrl: string; skipAlert: boolean; } diff --git a/packages/pl-fe/src/actions/export-data.ts b/packages/pl-fe/src/actions/export-data.ts index d91b1760b..9c28c1911 100644 --- a/packages/pl-fe/src/actions/export-data.ts +++ b/packages/pl-fe/src/actions/export-data.ts @@ -27,15 +27,16 @@ const messages = defineMessages({ type ExportDataAction = { type: typeof EXPORT_FOLLOWS_REQUEST - | typeof EXPORT_FOLLOWS_SUCCESS - | typeof EXPORT_FOLLOWS_FAIL | typeof EXPORT_BLOCKS_REQUEST - | typeof EXPORT_BLOCKS_SUCCESS - | typeof EXPORT_BLOCKS_FAIL | typeof EXPORT_MUTES_REQUEST - | typeof EXPORT_MUTES_SUCCESS + | typeof EXPORT_FOLLOWS_SUCCESS + | typeof EXPORT_BLOCKS_SUCCESS + | typeof EXPORT_MUTES_SUCCESS; +} | { + type: typeof EXPORT_FOLLOWS_FAIL + | typeof EXPORT_BLOCKS_FAIL | typeof EXPORT_MUTES_FAIL; - error?: any; + error?: unknown; } const fileExport = (content: string, fileName: string) => { diff --git a/packages/pl-fe/src/actions/import-data.ts b/packages/pl-fe/src/actions/import-data.ts index b5a01f72b..1f991bfc7 100644 --- a/packages/pl-fe/src/actions/import-data.ts +++ b/packages/pl-fe/src/actions/import-data.ts @@ -20,16 +20,18 @@ const IMPORT_MUTES_FAIL = 'IMPORT_MUTES_FAIL' as const; type ImportDataActions = { type: typeof IMPORT_FOLLOWS_REQUEST - | typeof IMPORT_FOLLOWS_SUCCESS - | typeof IMPORT_FOLLOWS_FAIL | typeof IMPORT_BLOCKS_REQUEST + | typeof IMPORT_MUTES_REQUEST; +} | { + type: typeof IMPORT_FOLLOWS_SUCCESS | typeof IMPORT_BLOCKS_SUCCESS - | typeof IMPORT_BLOCKS_FAIL - | typeof IMPORT_MUTES_REQUEST - | typeof IMPORT_MUTES_SUCCESS - | typeof IMPORT_MUTES_FAIL; - error?: any; + | typeof IMPORT_MUTES_SUCCESS; response?: string; +} | { + type: | typeof IMPORT_FOLLOWS_FAIL + | typeof IMPORT_BLOCKS_FAIL + | typeof IMPORT_MUTES_FAIL; + error?: unknown; } const messages = defineMessages({ diff --git a/packages/pl-fe/src/actions/instance.ts b/packages/pl-fe/src/actions/instance.ts index 3eb5cbcbb..4363b121e 100644 --- a/packages/pl-fe/src/actions/instance.ts +++ b/packages/pl-fe/src/actions/instance.ts @@ -26,7 +26,7 @@ interface InstanceFetchSuccessAction { interface InstanceFetchFailAction { type: typeof INSTANCE_FETCH_FAIL; - error: any; + error: unknown; } const fetchInstance = () => async (dispatch: AppDispatch, getState: () => RootState) => { diff --git a/packages/pl-fe/src/actions/lists.ts b/packages/pl-fe/src/actions/lists.ts index e1de73e33..463f151c5 100644 --- a/packages/pl-fe/src/actions/lists.ts +++ b/packages/pl-fe/src/actions/lists.ts @@ -310,7 +310,7 @@ const addToListSuccess = (listId: string, accountId: string) => ({ accountId, }); -const addToListFail = (listId: string, accountId: string, error: any) => ({ +const addToListFail = (listId: string, accountId: string, error: unknown) => ({ type: LIST_EDITOR_ADD_FAIL, listId, accountId, diff --git a/packages/pl-fe/src/actions/media.ts b/packages/pl-fe/src/actions/media.ts index 7bfd4b293..0879dfe6f 100644 --- a/packages/pl-fe/src/actions/media.ts +++ b/packages/pl-fe/src/actions/media.ts @@ -16,10 +16,10 @@ const messages = defineMessages({ exceededVideoDurationLimit: { id: 'upload_error.video_duration_limit', defaultMessage: 'Video exceeds the current duration limit ({limit, plural, one {# second} other {# seconds}})' }, }); -const noOp = (e: any) => {}; +const noOp = () => {}; const updateMedia = (mediaId: string, params: Record) => - (dispatch: any, getState: () => RootState) => + (_dispatch: AppDispatch, getState: () => RootState) => getClient(getState()).media.updateMedia(mediaId, params); const uploadMedia = (body: UploadMediaParams, onUploadProgress: (e: ProgressEvent) => void = noOp) => diff --git a/packages/pl-fe/src/actions/timelines.ts b/packages/pl-fe/src/actions/timelines.ts index dfc5f3a12..487039ff7 100644 --- a/packages/pl-fe/src/actions/timelines.ts +++ b/packages/pl-fe/src/actions/timelines.ts @@ -6,7 +6,17 @@ import { getClient } from '../api'; import { importEntities } from './importer'; -import type { PaginatedResponse, Status as BaseStatus, PublicTimelineParams, HomeTimelineParams, ListTimelineParams, HashtagTimelineParams, GetAccountStatusesParams, GroupTimelineParams } from 'pl-api'; +import type { + Account as BaseAccount, + GetAccountStatusesParams, + GroupTimelineParams, + HashtagTimelineParams, + HomeTimelineParams, + ListTimelineParams, + PaginatedResponse, + PublicTimelineParams, + Status as BaseStatus, +} from 'pl-api'; import type { AppDispatch, RootState } from 'pl-fe/store'; const TIMELINE_UPDATE = 'TIMELINE_UPDATE' as const; @@ -133,20 +143,16 @@ const parseTags = (tags: Record = {}, mode: 'any' | 'all' | 'none (tags[mode] || []).map((tag) => tag.value); const deduplicateStatuses = (statuses: Array) => { - const deduplicatedStatuses: any[] = []; + const deduplicatedStatuses: Array }> = []; for (const status of statuses) { const reblogged = status.reblog && deduplicatedStatuses.find((deduplicatedStatus) => deduplicatedStatus.reblog?.id === status.reblog?.id); if (reblogged) { - if (reblogged.accounts) { - reblogged.accounts.push(status.account); - } else { - reblogged.accounts = [reblogged.account, status.account]; - } + reblogged.accounts.push(status.account); reblogged.id += ':' + status.id; } else if (!deduplicatedStatuses.find((deduplicatedStatus) => deduplicatedStatus.reblog?.id === status.id)) { - deduplicatedStatuses.push(status); + deduplicatedStatuses.push({ accounts: [status.account], ...status }); } } diff --git a/packages/pl-fe/src/components/search-input.tsx b/packages/pl-fe/src/components/search-input.tsx index be7dc2ade..11460b297 100644 --- a/packages/pl-fe/src/components/search-input.tsx +++ b/packages/pl-fe/src/components/search-input.tsx @@ -7,14 +7,16 @@ import AutosuggestAccountInput from 'pl-fe/components/autosuggest-account-input' import SvgIcon from 'pl-fe/components/ui/svg-icon'; import { useAppDispatch } from 'pl-fe/hooks/use-app-dispatch'; import { selectAccount } from 'pl-fe/selectors'; -import { AppDispatch, RootState } from 'pl-fe/store'; + +import type { AppDispatch, RootState } from 'pl-fe/store'; +import type { History } from 'pl-fe/types/history'; const messages = defineMessages({ placeholder: { id: 'search.placeholder', defaultMessage: 'Search' }, action: { id: 'search.action', defaultMessage: 'Search for “{query}”' }, }); -const redirectToAccount = (accountId: string, routerHistory: any) => +const redirectToAccount = (accountId: string, routerHistory: History) => (_dispatch: AppDispatch, getState: () => RootState) => { const acct = selectAccount(getState(), accountId)!.acct; diff --git a/packages/pl-fe/src/iframe.ts b/packages/pl-fe/src/iframe.ts index 7e578aa3f..ae4893bc4 100644 --- a/packages/pl-fe/src/iframe.ts +++ b/packages/pl-fe/src/iframe.ts @@ -1,5 +1,5 @@ /** ID of this iframe (given by embed.js) when embedded on a page. */ -let iframeId: any; +let iframeId: string; /** Receive iframe messages. */ // https://github.com/mastodon/mastodon/pull/4853 diff --git a/packages/pl-fe/src/reducers/meta.ts b/packages/pl-fe/src/reducers/meta.ts index 6a47da2b5..78e5e9f3b 100644 --- a/packages/pl-fe/src/reducers/meta.ts +++ b/packages/pl-fe/src/reducers/meta.ts @@ -8,7 +8,7 @@ const initialState = { const meta = (state = initialState, action: InstanceAction): typeof initialState => { switch (action.type) { case INSTANCE_FETCH_FAIL: - if (action.error?.response?.status === 404) { + if ((action.error as any)?.response?.status === 404) { return { instance_fetch_failed: true }; } return state;