From d7107889026cf3c82409916a5f4fb14f7e5d6c5f Mon Sep 17 00:00:00 2001 From: Alex Freska Date: Fri, 20 Sep 2024 12:12:17 -0400 Subject: [PATCH] refactor(renterd): typescript strict mode --- .vscode/settings.json | 3 +- apps/hostd/contexts/config/fields.tsx | 2 +- apps/hostd/dialogs/VolumeCreateDialog.tsx | 7 +- .../components/Alerts/AlertsFilterMenu.tsx | 7 +- apps/renterd/components/Alerts/index.tsx | 2 - apps/renterd/components/CmdRoot/Item.tsx | 8 +- .../Contracts/ContractContextMenu.tsx | 48 +- .../ContractFilterCmdGroups/Address.tsx | 2 +- .../ContractFilterCmdGroups/ContractSet.tsx | 2 +- .../ContractFilterCmdGroups/PublicKey.tsx | 2 +- .../ContractFilterCmdGroups/index.tsx | 4 +- .../ContractsFilterContractSetDialog.tsx | 5 +- .../Contracts/ContractsFilterMenu/index.tsx | 6 +- .../FilesHealthColumnContents.tsx | 4 +- .../Files/FilesCmd/FilesSearchCmd/index.tsx | 4 +- .../components/Files/FilesCmd/index.tsx | 4 +- .../EmptyState/StateNoneYetBuckets.tsx | 27 + ...StateNoneYet.tsx => StateNoneYetFiles.tsx} | 2 +- .../FilesDirectory/EmptyState/index.tsx | 10 +- .../components/Hosts/HostContextMenu.tsx | 19 +- .../components/Hosts/HostMap/Globe.tsx | 13 +- .../components/Hosts/HostMap/GlobeDyn.tsx | 1 + .../components/Hosts/HostMap/HostItem.tsx | 20 +- .../renterd/components/Hosts/HostMap/utils.ts | 14 +- .../HostsFilterCmdGroups/Address.tsx | 2 +- .../HostsFilterCmdGroups/PublicKey.tsx | 2 +- .../Hosts/HostsFilterMenu/index.tsx | 6 +- .../components/Keys/KeysCreateDialog.tsx | 10 +- apps/renterd/components/Keys/index.tsx | 2 - apps/renterd/components/Profile/index.tsx | 4 +- apps/renterd/components/TransferProgress.tsx | 4 +- apps/renterd/components/TransfersBar.tsx | 2 +- .../Uploads/UploadsBreadcrumbMenu.tsx | 7 +- apps/renterd/contexts/alerts/columns.tsx | 18 +- apps/renterd/contexts/alerts/data.tsx | 212 +++--- apps/renterd/contexts/alerts/index.tsx | 7 +- apps/renterd/contexts/app/useBusSdk.tsx | 2 +- apps/renterd/contexts/contracts/columns.tsx | 107 +-- apps/renterd/contexts/contracts/dataset.tsx | 12 +- apps/renterd/contexts/contracts/index.tsx | 4 +- .../contracts/useContractSetMetrics.tsx | 3 +- .../contexts/contracts/useFilteredStats.tsx | 6 +- .../contracts/usePrunableContractSizes.tsx | 13 +- apps/renterd/contexts/dialog.tsx | 2 +- .../contexts/filesDirectory/columns.tsx | 6 +- .../contexts/filesDirectory/dataset.tsx | 2 +- .../renterd/contexts/filesDirectory/index.tsx | 2 +- apps/renterd/contexts/filesDirectory/move.tsx | 12 +- apps/renterd/contexts/filesFlat/columns.tsx | 6 +- apps/renterd/contexts/filesFlat/dataset.tsx | 1 + apps/renterd/contexts/filesFlat/index.tsx | 3 +- .../renterd/contexts/filesManager/dataset.tsx | 6 +- .../contexts/filesManager/downloads.tsx | 4 + .../contexts/filesManager/index.spec.tsx | 40 +- apps/renterd/contexts/filesManager/index.tsx | 8 +- apps/renterd/contexts/filesManager/types.ts | 14 +- .../renterd/contexts/filesManager/uploads.tsx | 29 +- apps/renterd/contexts/hosts/columns.tsx | 35 +- apps/renterd/contexts/hosts/dataset.ts | 53 +- apps/renterd/contexts/hosts/index.tsx | 19 +- apps/renterd/contexts/hosts/types.tsx | 8 +- apps/renterd/contexts/keys/columns.tsx | 12 +- apps/renterd/contexts/keys/index.tsx | 11 +- apps/renterd/contexts/transactions/index.tsx | 6 +- apps/renterd/contexts/uploads/columns.tsx | 6 +- apps/renterd/contexts/uploads/index.tsx | 94 +-- apps/renterd/dialogs/FileRenameDialog.tsx | 3 + .../dialogs/FilesBucketDeleteDialog.tsx | 2 +- .../dialogs/FilesBucketPolicyDialog.tsx | 10 +- .../dialogs/FilesCreateDirectoryDialog.tsx | 1 + .../dialogs/RenterdSendSiacoinDialog.tsx | 2 +- .../RenterdTransactionDetailsDialog.tsx | 2 +- apps/renterd/hooks/useHealthLabel.tsx | 4 +- apps/renterd/hooks/useSyncStatus.ts | 11 +- apps/renterd/jest.polyfills.js | 4 +- apps/renterd/lib/health.ts | 4 +- apps/renterd/lib/multipartUpload.spec.ts | 60 +- apps/renterd/lib/multipartUpload.ts | 47 +- apps/renterd/lib/rename.ts | 4 +- apps/renterd/tsconfig.json | 2 +- apps/walletd/jest.polyfills.js | 4 +- libs/design-system/jest.polyfills.js | 4 +- .../src/app/TransactionDetailsDialog.tsx | 4 +- .../app/WalletSingleAddressDetailsDialog.tsx | 4 +- .../src/components/Table/TableRow.tsx | 4 +- .../src/components/Table/index.tsx | 6 +- libs/design-system/src/form/FieldFiat.tsx | 8 +- libs/design-system/src/form/FieldNumber.tsx | 8 +- libs/design-system/src/form/FieldSelect.tsx | 8 +- libs/design-system/src/form/FieldSiacoin.tsx | 8 +- libs/design-system/src/form/FieldSwitch.tsx | 8 +- libs/design-system/src/form/FieldText.tsx | 8 +- libs/design-system/src/form/FieldTextArea.tsx | 8 +- .../src/form/configurationFields.ts | 36 +- .../src/hooks/useClientFilteredDataset.ts | 6 +- .../src/hooks/useSiacoinFiat.tsx | 16 +- libs/design-system/src/index.ts | 1 + libs/design-system/src/lib/object.ts | 4 +- libs/design-system/src/lib/types.ts | 5 + libs/react-icons/src/BucketIcon.tsx | 4 +- libs/sdk/jest.polyfills.js | 4 +- libs/units/src/events.ts | 2 +- libs/units/src/storage.ts | 22 +- libs/units/src/transactionTypes.ts | 10 +- package-lock.json | 614 +++++++++++------- package.json | 4 +- 106 files changed, 1204 insertions(+), 780 deletions(-) create mode 100644 apps/renterd/components/FilesDirectory/EmptyState/StateNoneYetBuckets.tsx rename apps/renterd/components/FilesDirectory/EmptyState/{StateNoneYet.tsx => StateNoneYetFiles.tsx} (97%) create mode 100644 libs/design-system/src/lib/types.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index 37328ce58..7f96ae453 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,5 +12,6 @@ "GOOS": "js", "GOARCH": "wasm" } - } + }, + "typescript.tsdk": "node_modules/typescript/lib" } diff --git a/apps/hostd/contexts/config/fields.tsx b/apps/hostd/contexts/config/fields.tsx index b18f219e3..8511f3b48 100644 --- a/apps/hostd/contexts/config/fields.tsx +++ b/apps/hostd/contexts/config/fields.tsx @@ -1,6 +1,6 @@ /* eslint-disable react/no-unescaped-entities */ import { blocksToMonths } from '@siafoundation/units' -import { ConfigFields } from '@siafoundation/design-system' +import { ConfigFields, Maybe } from '@siafoundation/design-system' import BigNumber from 'bignumber.js' import { ConfigViewMode, diff --git a/apps/hostd/dialogs/VolumeCreateDialog.tsx b/apps/hostd/dialogs/VolumeCreateDialog.tsx index 17121cee2..5d7adf6bb 100644 --- a/apps/hostd/dialogs/VolumeCreateDialog.tsx +++ b/apps/hostd/dialogs/VolumeCreateDialog.tsx @@ -67,7 +67,8 @@ function getFields( validation: { required: 'required', validate: { - req: (value) => value !== '\\' || 'directory within a drive required', + req: (value: string) => + value !== '\\' || 'directory within a drive required', }, }, }, @@ -80,11 +81,11 @@ function getFields( validation: { required: 'required', validate: { - between: (value: number) => { + between: (value: BigNumber) => { const error = `Must be between ${humanBytes( GBToBytes(minSizeGB) )} and ${humanBytes(GBToBytes(maxSizeGB), { fixed: 3 })}` - return (value <= maxSizeGB && value >= minSizeGB) || error + return (value.lte(maxSizeGB) && value.gte(minSizeGB)) || error }, nospace: () => maxSizeGB > minSizeGB || 'not enough space in directory', diff --git a/apps/renterd/components/Alerts/AlertsFilterMenu.tsx b/apps/renterd/components/Alerts/AlertsFilterMenu.tsx index 7ab34f9fd..48cde694b 100644 --- a/apps/renterd/components/Alerts/AlertsFilterMenu.tsx +++ b/apps/renterd/components/Alerts/AlertsFilterMenu.tsx @@ -56,7 +56,12 @@ export function AlertsFilterMenu() { {!dataState && !!pageCount && (