From 771a863b3729fab705fccdc0e435cd851eeb9734 Mon Sep 17 00:00:00 2001 From: somebody1234 Date: Thu, 19 Dec 2024 20:18:17 +1000 Subject: [PATCH] Fix type errors --- app/gui/src/common/services/LocalBackend.ts | 2 +- app/gui/src/common/services/RemoteBackend.ts | 8 +++----- app/gui/src/dashboard/App.tsx | 4 ++-- app/gui/src/dashboard/hooks/backendHooks.tsx | 2 +- .../dashboard/layouts/Settings/MembersSettingsSection.tsx | 2 +- app/gui/src/dashboard/layouts/Settings/data.tsx | 4 ++-- app/gui/src/dashboard/providers/AuthProvider.tsx | 2 +- app/gui/src/dashboard/providers/BackendProvider.tsx | 4 ++-- 8 files changed, 13 insertions(+), 15 deletions(-) diff --git a/app/gui/src/common/services/LocalBackend.ts b/app/gui/src/common/services/LocalBackend.ts index 1648afa1fd96..0e67a5388166 100644 --- a/app/gui/src/common/services/LocalBackend.ts +++ b/app/gui/src/common/services/LocalBackend.ts @@ -140,7 +140,7 @@ export function extractTypeAndId(id: Id): AssetTypeAndId { * Class for sending requests to the Project Manager API endpoints. * This is used instead of the cloud backend API when managing local projects from the dashboard. */ -export default class LocalBackend extends Backend { +export class LocalBackend extends Backend { readonly type = BackendType.local /** All files that have been uploaded to the Project Manager. */ uploadedFiles: Map = new Map() diff --git a/app/gui/src/common/services/RemoteBackend.ts b/app/gui/src/common/services/RemoteBackend.ts index 7f6b6d6115e9..f3a1c09a38a0 100644 --- a/app/gui/src/common/services/RemoteBackend.ts +++ b/app/gui/src/common/services/RemoteBackend.ts @@ -226,7 +226,7 @@ interface RemoteBackendPostOptions { } /** Class for sending requests to the Cloud backend API endpoints. */ -export default class RemoteBackend extends Backend { +export class RemoteBackend extends Backend { readonly type = BackendType.remote private user: Mutable | null = null @@ -268,7 +268,6 @@ export default class RemoteBackend extends Backend { response == null || response.headers.get('Content-Type') !== 'application/json' ? { message: 'unknown error' } // This is SAFE only when the response has been confirmed to have an erroring status code. - // eslint-disable-next-line no-restricted-syntax : ((await response.json()) as RemoteBackendError) const message = `${this.getText(textId, ...replacements)}: ${error.message}.` this.logger.error(message) @@ -436,7 +435,7 @@ export default class RemoteBackend extends Backend { /** Upload a new profile picture for the current user. */ override async uploadUserPicture(params: UploadPictureRequestParams, file: Blob): Promise { const paramsString = new URLSearchParams({ - // eslint-disable-next-line @typescript-eslint/naming-convention, camelcase + // eslint-disable-next-line camelcase ...(params.fileName != null ? { file_name: params.fileName } : {}), }).toString() const path = `${UPLOAD_USER_PICTURE_PATH}?${paramsString}` @@ -504,7 +503,7 @@ export default class RemoteBackend extends Backend { file: Blob, ): Promise { const paramsString = new URLSearchParams({ - // eslint-disable-next-line @typescript-eslint/naming-convention, camelcase + // eslint-disable-next-line camelcase ...(params.fileName != null ? { file_name: params.fileName } : {}), }).toString() const path = `${UPLOAD_ORGANIZATION_PICTURE_PATH}?${paramsString}` @@ -594,7 +593,6 @@ export default class RemoteBackend extends Backend { const ret = (await response.json()).assets .map((asset) => merge(asset, { - // eslint-disable-next-line no-restricted-syntax type: asset.id.match(/^(.+?)-/)?.[1] as AssetType, // `Users` and `Teams` folders are virtual, so their children incorrectly have // the organization root id as their parent id. diff --git a/app/gui/src/dashboard/App.tsx b/app/gui/src/dashboard/App.tsx index 4a565d2d97e0..2fe3c0b04541 100644 --- a/app/gui/src/dashboard/App.tsx +++ b/app/gui/src/dashboard/App.tsx @@ -109,9 +109,9 @@ import { APP_BASE_URL } from '#/utilities/appBaseUrl' import { isElementPartOfMonaco, isElementTextInput } from '#/utilities/event' import LocalStorage from '#/utilities/LocalStorage' import { STATIC_QUERY_OPTIONS } from '#/utilities/reactQuery' -import LocalBackend from '@common/services/LocalBackend' +import { LocalBackend } from '@common/services/LocalBackend' import ProjectManager, * as projectManager from '@common/services/ProjectManager' -import RemoteBackend from '@common/services/RemoteBackend' +import { RemoteBackend } from '@common/services/RemoteBackend' declare module '#/utilities/LocalStorage' { /** */ diff --git a/app/gui/src/dashboard/hooks/backendHooks.tsx b/app/gui/src/dashboard/hooks/backendHooks.tsx index b7dd0d94db5a..8407a18d1555 100644 --- a/app/gui/src/dashboard/hooks/backendHooks.tsx +++ b/app/gui/src/dashboard/hooks/backendHooks.tsx @@ -74,7 +74,7 @@ import { useSetModal } from '#/providers/ModalProvider' import { useText } from '#/providers/TextProvider' import { tryCreateOwnerPermission } from '#/utilities/permissions' import { usePreventNavigation } from '#/utilities/preventNavigation' -import LocalBackend from '@common/services/LocalBackend' +import { LocalBackend } from '@common/services/LocalBackend' import { TEAMS_DIRECTORY_ID, USERS_DIRECTORY_ID } from '@common/services/remoteBackendPaths' // The number of bytes in 1 megabyte. diff --git a/app/gui/src/dashboard/layouts/Settings/MembersSettingsSection.tsx b/app/gui/src/dashboard/layouts/Settings/MembersSettingsSection.tsx index e43356b592b9..e901b193ebb3 100644 --- a/app/gui/src/dashboard/layouts/Settings/MembersSettingsSection.tsx +++ b/app/gui/src/dashboard/layouts/Settings/MembersSettingsSection.tsx @@ -11,7 +11,7 @@ import InviteUsersModal from '#/modals/InviteUsersModal' import { useFullUserSession } from '#/providers/AuthProvider' import { useRemoteBackend } from '#/providers/BackendProvider' import { useText } from '#/providers/TextProvider' -import type RemoteBackend from '@common/services/RemoteBackend' +import type { RemoteBackend } from '@common/services/RemoteBackend' const LIST_USERS_STALE_TIME_MS = 60_000 diff --git a/app/gui/src/dashboard/layouts/Settings/data.tsx b/app/gui/src/dashboard/layouts/Settings/data.tsx index 69d66dd60d13..40344c553f48 100644 --- a/app/gui/src/dashboard/layouts/Settings/data.tsx +++ b/app/gui/src/dashboard/layouts/Settings/data.tsx @@ -31,8 +31,8 @@ import type { ToastAndLogCallback } from '#/hooks/toastAndLogHooks' import { passwordWithPatternSchema } from '#/pages/authentication/schemas' import type { GetText } from '#/providers/TextProvider' import { PASSWORD_REGEX } from '#/utilities/validation' -import type LocalBackend from '@common/services/LocalBackend' -import type RemoteBackend from '@common/services/RemoteBackend' +import type { LocalBackend } from '@common/services/LocalBackend' +import type { RemoteBackend } from '@common/services/RemoteBackend' import ActivityLogSettingsSection from './ActivityLogSettingsSection' import DeleteUserAccountSettingsSection from './DeleteUserAccountSettingsSection' import KeyboardShortcutsSettingsSection from './KeyboardShortcutsSettingsSection' diff --git a/app/gui/src/dashboard/providers/AuthProvider.tsx b/app/gui/src/dashboard/providers/AuthProvider.tsx index da1aae441415..dc5c7f3097b2 100644 --- a/app/gui/src/dashboard/providers/AuthProvider.tsx +++ b/app/gui/src/dashboard/providers/AuthProvider.tsx @@ -47,7 +47,7 @@ import { useText } from '#/providers/TextProvider' import { Dialog } from '#/components/AriaComponents' import { Result } from '#/components/Result' -import type RemoteBackend from '@common/services/RemoteBackend' +import type { RemoteBackend } from '@common/services/RemoteBackend' import { CognitoErrorType, diff --git a/app/gui/src/dashboard/providers/BackendProvider.tsx b/app/gui/src/dashboard/providers/BackendProvider.tsx index 87c2d81a989e..31e7a47a3b33 100644 --- a/app/gui/src/dashboard/providers/BackendProvider.tsx +++ b/app/gui/src/dashboard/providers/BackendProvider.tsx @@ -12,9 +12,9 @@ import * as common from 'enso-common' import { type Category, isCloudCategory } from '#/layouts/CategorySwitcher/Category' import { useEventCallback } from '#/hooks/eventCallbackHooks' -import type LocalBackend from '@common/services/LocalBackend' +import type { LocalBackend } from '@common/services/LocalBackend' import { ProjectManagerEvents } from '@common/services/ProjectManager' -import type RemoteBackend from '@common/services/RemoteBackend' +import type { RemoteBackend } from '@common/services/RemoteBackend' /** State contained in a `BackendContext`. */ export interface BackendContextType {