diff --git a/src/components/form/Upload/WithUploadToIpfs.tsx b/src/components/form/Upload/WithUploadToIpfs.tsx index a77098f26..9d0f07888 100644 --- a/src/components/form/Upload/WithUploadToIpfs.tsx +++ b/src/components/form/Upload/WithUploadToIpfs.tsx @@ -70,7 +70,7 @@ export function WithUploadToIpfs

( return false; } - const ipfsArray = []; + const ipfsArray: FileProps[] = []; for (let i = 0; i < filesArray.length; i++) { const file = filesArray[i]; const cid = await saveFile(file); diff --git a/src/components/modal/components/Profile/utils.ts b/src/components/modal/components/Profile/utils.ts index ffb854db4..712178043 100644 --- a/src/components/modal/components/Profile/utils.ts +++ b/src/components/modal/components/Profile/utils.ts @@ -30,8 +30,14 @@ export function buildProfileFromMetadata( (img) => img.tag === "cover" ); const isLens = useLens && lensProfile; - let lensCoverPicture = null, - lensProfileImage = null; + let lensCoverPicture: { + url: string; + type: string; + } | null = null; + let lensProfileImage: { + url: string; + type: string; + } | null = null; if (isLens) { const lensCoverPictureUrl = getLensCoverPictureUrl(lensProfile); const lensCoverPictureType = lensCoverPictureUrl @@ -68,17 +74,16 @@ export function buildProfileFromMetadata( { ...coverPicture, src: coverPicture.url, - fit: "fit" in coverPicture ? coverPicture.fit : undefined, + fit: + "fit" in coverPicture ? (coverPicture.fit as string) : undefined, position: "position" in coverPicture - ? coverPicture.position ?? undefined + ? (coverPicture.position as string) || undefined : undefined } - ] ?? [] - : [], - logo: profileImage - ? [{ ...profileImage, src: profileImage.url }] ?? [] + ] : [], + logo: profileImage ? [{ ...profileImage, src: profileImage.url }] : [], contactPreference: OPTIONS_CHANNEL_COMMUNICATIONS_PREFERENCE.find( (obj) => obj.value === metadata?.contactPreference diff --git a/src/components/product/ProductImages.tsx b/src/components/product/ProductImages.tsx index 2aa3fa24c..3a8f489e2 100644 --- a/src/components/product/ProductImages.tsx +++ b/src/components/product/ProductImages.tsx @@ -78,7 +78,7 @@ const getProductImageError = ( typeof Object.values(errors.productImages)?.[0] === "string" ? Object.values(errors.productImages)?.[0] : null; - return error; + return String(error); }; export default function ProductImages({ onChangeOneSetOfImages }: Props) { const { nextIsDisabled, values, errors } = useForm(); diff --git a/src/components/product/confirmProductDetailsPage/ConfirmProductDetails.tsx b/src/components/product/confirmProductDetailsPage/ConfirmProductDetails.tsx index b083ccbf9..76beb2e18 100644 --- a/src/components/product/confirmProductDetailsPage/ConfirmProductDetails.tsx +++ b/src/components/product/confirmProductDetailsPage/ConfirmProductDetails.tsx @@ -31,6 +31,7 @@ import { Warning } from "phosphor-react"; import { useMemo } from "react"; import styled from "styled-components"; +import { FileProps } from "../../form/Upload/types"; import { SectionTitle } from "../Product.styles"; import { getBundleItemName } from "../productDigital/getBundleItemName"; import { @@ -310,12 +311,12 @@ export default function ConfirmProductDetails({ ([name, images]) => { if ( !images || - !images.length || - !images?.[0]?.src + !(images as FileProps[]).length || + !(images as FileProps[])?.[0]?.src ) { return null; } - const [img] = images; + const [img] = images as FileProps[]; const imgSrc = img.src; return ( diff --git a/src/components/product/confirmProductDetailsPage/ConfirmProductDigital.tsx b/src/components/product/confirmProductDetailsPage/ConfirmProductDigital.tsx index 56d1d3110..72e73a5e5 100644 --- a/src/components/product/confirmProductDetailsPage/ConfirmProductDigital.tsx +++ b/src/components/product/confirmProductDetailsPage/ConfirmProductDigital.tsx @@ -56,11 +56,11 @@ export const ConfirmProductDigital: React.FC = () => {

  • Type: - {bi.type.label} + {bi.type?.label}
  • NFT type: - {bi.newNftType.label} + {bi.newNftType?.label}
  • Name: @@ -78,7 +78,7 @@ export const ConfirmProductDigital: React.FC = () => {
  • Buyer information required for transfer:{" "} - {bi.newNftBuyerTransferInfo.label} + {bi.newNftBuyerTransferInfo?.label}
  • @@ -91,11 +91,11 @@ export const ConfirmProductDigital: React.FC = () => {
  • Type: - {bi.type.label} + {bi.type?.label}
  • NFT type: - {bi.mintedNftType.label} + {bi.mintedNftType?.label}
  • ContractAddress:{" "} @@ -117,7 +117,7 @@ export const ConfirmProductDigital: React.FC = () => {
  • Buyer information required for transfer:{" "} - {bi.mintedNftBuyerTransferInfo.label} + {bi.mintedNftBuyerTransferInfo?.label}
  • @@ -130,7 +130,7 @@ export const ConfirmProductDigital: React.FC = () => {
  • Type: - {bi.type.label} + {bi.type?.label}
  • Name: {bi.digitalFileName} @@ -150,7 +150,7 @@ export const ConfirmProductDigital: React.FC = () => {
  • Buyer information required for transfer:{" "} - {bi.digitalFileBuyerTransferInfo.label} + {bi.digitalFileBuyerTransferInfo?.label}
  • @@ -163,7 +163,7 @@ export const ConfirmProductDigital: React.FC = () => {
  • Type: - {bi.type.label} + {bi.type?.label}
  • Name: {bi.experientialName} @@ -180,7 +180,7 @@ export const ConfirmProductDigital: React.FC = () => {
  • Buyer information required for transfer:{" "} - {bi.experientialBuyerTransferInfo.label} + {bi.experientialBuyerTransferInfo?.label}
  • diff --git a/src/components/product/utils/initialValues.ts b/src/components/product/utils/initialValues.ts index 73a27109a..247b820db 100644 --- a/src/components/product/utils/initialValues.ts +++ b/src/components/product/utils/initialValues.ts @@ -9,6 +9,7 @@ import { OPTIONS_PERIOD, OPTIONS_UNIT, OPTIONS_WEIGHT, + ProductTypeTypeValues, TOKEN_CRITERIA, TOKEN_TYPES } from "./const"; @@ -36,9 +37,9 @@ export const createYourProfileInitialValues: CreateYourProfile = { export const productTypeInitialValues = { productType: { - productType: "", + productType: "" as ProductTypeTypeValues, productVariant: "", - tokenGatedOffer: "" + tokenGatedOffer: "false" } } as const; @@ -176,7 +177,7 @@ export const shippingInfoInitialValues = { export const imagesSpecificOrAllInitialValues = { imagesSpecificOrAll: { - value: "all", + value: "all" as NonNullable<"all" | "specific" | undefined>, label: "All" } }; diff --git a/src/components/product/utils/validationSchema.ts b/src/components/product/utils/validationSchema.ts index bedfaeab7..60667ae55 100644 --- a/src/components/product/utils/validationSchema.ts +++ b/src/components/product/utils/validationSchema.ts @@ -7,8 +7,7 @@ import { import { Dayjs } from "dayjs"; import { ethers } from "ethers"; import { checkValidUrl, notUrlErrorMessage } from "lib/validation/regex/url"; -import { ValidationError } from "yup"; -import { AnyObject } from "yup/lib/types"; +import { AnyObject, ValidationError } from "yup"; import { validationMessage } from "../../../lib/constants/validationMessage"; import { fixformattedString } from "../../../lib/utils/number"; @@ -118,7 +117,7 @@ const getBundleItemsMedia = ({ Yup.object({ image: validationOfIpfsImage(), video: validationOfIpfsImage() - }).nullable(true) + }).nullable() ).test( "invalidBundleItemsMedia", "Please add an image for new NFTs", @@ -347,7 +346,7 @@ const transferCriteria = Yup.string().required(validationMessage.required); const transferTime = Yup.number() .min(0, "It cannot be negative") .required(validationMessage.required) - .nullable(true); + .nullable(); const transferTimeUnit = Yup.object({ value: Yup.string(), label: Yup.string() @@ -362,7 +361,7 @@ const buyerTransferInfo = Yup.object({ label: Yup.string() }) .required(validationMessage.required) - .nullable(true); + .nullable(); const testTokenAddress = async function ({ tokenType, coreSDK, @@ -472,7 +471,7 @@ const commonFieldsBundleItem = { label: Yup.string() }) .required(validationMessage.required) - .nullable(true) + .nullable() .default(undefined), isNftMintedAlready: Yup.object({ value: Yup.string().oneOf( @@ -488,7 +487,7 @@ const commonFieldsBundleItem = { otherwise: (schema) => schema }) .default(undefined) - .nullable(true) + .nullable() }; const nftType = Yup.object({ value: Yup.string() @@ -497,7 +496,7 @@ const nftType = Yup.object({ label: Yup.string() }) .required(validationMessage.required) - .nullable(true); + .nullable(); const getExistingNftSchema = ({ coreSDK }: { coreSDK: CoreSDK }) => Yup.object({ ...commonFieldsBundleItem, @@ -511,7 +510,7 @@ const getExistingNftSchema = ({ coreSDK }: { coreSDK: CoreSDK }) => label: Yup.string() }) .required(validationMessage.required) - .nullable(true) + .nullable() .default([{ value: "", label: "" }]), mintedNftContractAddress: Yup.string() .required(validationMessage.required) @@ -690,30 +689,32 @@ export const commonCoreTermsOfSaleValidationSchema = { offerValidityPeriod: Yup.mixed() .when("infiniteExpirationOffers", { is: true, - then: Yup.mixed() - .required(validationMessage.required) - .defined(validationMessage.required), - otherwise: Yup.mixed() - .required(validationMessage.required) - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - .isOfferValidityDatesValid() + then: (schema) => + schema + .required(validationMessage.required) + .defined(validationMessage.required), + otherwise: (schema) => + schema + .required(validationMessage.required) + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + .isOfferValidityDatesValid() }) .required(validationMessage.required), redemptionPeriod: Yup.mixed().when( "infiniteExpirationOffers", { is: true, - then: Yup.mixed().optional(), + then: (schema) => schema.optional(), // .required(validationMessage.required) // .defined(validationMessage.required), - otherwise: Yup.mixed() - // Yup.array() - .required(validationMessage.required) - // .min(2, validationMessage.required) - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - .isRedemptionDatesValid() + otherwise: (schema) => + schema + .required(validationMessage.required) + // .min(2, validationMessage.required) + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + .isRedemptionDatesValid() } ), voucherValidDurationInDays: Yup.number().when("infiniteExpirationOffers", { @@ -723,7 +724,7 @@ export const commonCoreTermsOfSaleValidationSchema = { .required(validationMessage.required) .min(1, "It has to be 1 at least"); }, - otherwise: Yup.number().min(0, "It must be 0").max(0, "It must be 0") + otherwise: (schema) => schema.min(0, "It must be 0").max(0, "It must be 0") }) }; diff --git a/src/components/searchModal/CurrencySearchModal.tsx b/src/components/searchModal/CurrencySearchModal.tsx index e3e1a3665..57308d795 100644 --- a/src/components/searchModal/CurrencySearchModal.tsx +++ b/src/components/searchModal/CurrencySearchModal.tsx @@ -3,7 +3,7 @@ import Modal from "components/modal/Modal"; import TokenSafety from "components/tokenSafety"; import { useLast } from "lib/utils/hooks/useLast"; import { useWindowSize } from "lib/utils/hooks/useWindowSize"; -import { memo, useCallback, useEffect, useState } from "react"; +import { memo, ReactElement, useCallback, useEffect, useState } from "react"; import { useUserAddedTokens } from "state/user/hooks"; import styled from "styled-components"; @@ -84,7 +84,7 @@ export default memo(function CurrencySearchModal({ const { height: windowHeight } = useWindowSize(); // change min height if not searching let modalHeight: number | undefined = 80; - let content = null; + let content: ReactElement | null = null; switch (modalView) { case CurrencyModalView.search: if (windowHeight) { diff --git a/src/components/tokenSafety/index.tsx b/src/components/tokenSafety/index.tsx index 62c623410..f847d133d 100644 --- a/src/components/tokenSafety/index.tsx +++ b/src/components/tokenSafety/index.tsx @@ -19,6 +19,7 @@ import { ExplorerDataType, getExplorerLink } from "lib/utils/getExplorerLink"; import { useToken } from "lib/utils/hooks/Tokens"; import { ArrowSquareOut as LinkIconFeather, Copy } from "phosphor-react"; import { lighten } from "polished"; +import { ReactElement } from "react-markdown/lib/react-markdown"; import { useAddUserToken } from "state/user/hooks"; import styled from "styled-components"; @@ -230,8 +231,8 @@ export default function TokenSafety({ onBlocked, showCancel }: TokenSafetyProps) { - const logos = []; - const urls = []; + const logos: ReactElement[] = []; + const urls: ReactElement[] = []; const token1Warning = tokenAddress ? checkWarning(tokenAddress) : null; const token1 = useToken(tokenAddress); diff --git a/src/lib/constants/tokenSafety.tsx b/src/lib/constants/tokenSafety.tsx index 5a17dfdf8..6288d901f 100644 --- a/src/lib/constants/tokenSafety.tsx +++ b/src/lib/constants/tokenSafety.tsx @@ -1,4 +1,5 @@ import { constants } from "ethers"; +import { ReactElement } from "react"; import { NATIVE_CHAIN_ID } from "./tokens"; import tokenSafetyLookup, { TOKEN_LIST_TYPES } from "./tokenSafetyLookup"; @@ -13,8 +14,8 @@ export enum WARNING_LEVEL { } export function getWarningCopy(warning: Warning | null, plural = false) { - let heading = null, - description = null; + let heading: ReactElement | null = null, + description: ReactElement | null = null; if (warning) { switch (warning.level) { case WARNING_LEVEL.MEDIUM: diff --git a/src/lib/utils/files.ts b/src/lib/utils/files.ts index e9fc37d36..61a1098cb 100644 --- a/src/lib/utils/files.ts +++ b/src/lib/utils/files.ts @@ -3,7 +3,7 @@ export type FileWithEncodedData = File & { encodedData: string }; export const getFilesWithEncodedData = async ( files: File[] ): Promise => { - const promises = []; + const promises: Array> = []; for (const file of files as FileWithEncodedData[]) { promises.push( new Promise((resolve, reject) => { diff --git a/src/lib/utils/hooks/chat/getThreadWorker.ts b/src/lib/utils/hooks/chat/getThreadWorker.ts index 72ea716b6..22fbd0d6e 100644 --- a/src/lib/utils/hooks/chat/getThreadWorker.ts +++ b/src/lib/utils/hooks/chat/getThreadWorker.ts @@ -179,7 +179,14 @@ function getTimesInFailedPeriod(failedTimesArray: Time[]) { if (dateStep === time.dateStep) { return null; } - const subTimePeriods = []; + const subTimePeriods: { + startTime: Date; + endTime: Date; + isBeginning: boolean; + dateStep: DateStep; + dateStepValue: number; + genesisDate: Date; + }[] = []; let iDateIndex = 1; let from = time.startTime; while (dayjs(from).isBefore(time.endTime)) { diff --git a/src/lib/utils/hooks/chat/useInfiniteThread.ts b/src/lib/utils/hooks/chat/useInfiniteThread.ts index 7ad58fb79..e57827f73 100644 --- a/src/lib/utils/hooks/chat/useInfiniteThread.ts +++ b/src/lib/utils/hooks/chat/useInfiniteThread.ts @@ -232,7 +232,7 @@ export function useInfiniteThread({ } const setIsValidToMessages = async (newThreadXmtp: ThreadObjectWithInfo) => { - const promises = []; + const promises: Array> = []; for (const message of newThreadXmtp.messages) { promises.push( message.isValid === undefined diff --git a/src/lib/utils/hooks/offers/useOffersWhitelist.ts b/src/lib/utils/hooks/offers/useOffersWhitelist.ts index 144d83d01..ec5f6285c 100644 --- a/src/lib/utils/hooks/offers/useOffersWhitelist.ts +++ b/src/lib/utils/hooks/offers/useOffersWhitelist.ts @@ -6,7 +6,7 @@ export const useOffersWhitelist = () => { const { config: { envConfig } } = useConfigContext(); - return useQuery( + return useQuery( ["useOffersWhitelist", envConfig.configId, envConfig.offersWhiteList], async () => { const response = await fetch(envConfig.offersWhiteList); diff --git a/src/lib/utils/product/extractUniqueRandomProducts.ts b/src/lib/utils/product/extractUniqueRandomProducts.ts index 9fa6b4d1f..be92e26a1 100644 --- a/src/lib/utils/product/extractUniqueRandomProducts.ts +++ b/src/lib/utils/product/extractUniqueRandomProducts.ts @@ -16,7 +16,7 @@ export default function extractUniqueRandomProducts({ quantity }: Props) { const sellerIdToProducts = groupBy(products, (p) => p.seller.id); - const productsToReturn = []; + const productsToReturn: ExtendedOffer[] = []; const maxProductsToReturn = Math.min(products.length, quantity); for ( let index = 0; diff --git a/src/lib/utils/transformSwapRouteToGetQuoteResult.ts b/src/lib/utils/transformSwapRouteToGetQuoteResult.ts index bb84ba2bc..e5a372199 100644 --- a/src/lib/utils/transformSwapRouteToGetQuoteResult.ts +++ b/src/lib/utils/transformSwapRouteToGetQuoteResult.ts @@ -40,7 +40,7 @@ export function transformSwapRouteToGetQuoteResult( const tokenIn = tokenPath[i]; const tokenOut = tokenPath[i + 1]; - let edgeAmountIn = undefined; + let edgeAmountIn: string | undefined = undefined; if (i === 0) { edgeAmountIn = tradeType === TradeType.EXACT_INPUT @@ -48,7 +48,7 @@ export function transformSwapRouteToGetQuoteResult( : quote.quotient.toString(); } - let edgeAmountOut = undefined; + let edgeAmountOut: string | undefined = undefined; if (i === pools.length - 1) { edgeAmountOut = tradeType === TradeType.EXACT_INPUT diff --git a/src/lib/validation/index.ts b/src/lib/validation/index.ts index 56e3f1718..c7777325f 100644 --- a/src/lib/validation/index.ts +++ b/src/lib/validation/index.ts @@ -7,7 +7,7 @@ import isOfferValidityDatesValid from "./isOfferValidityDatesValid"; import isRedemptionDatesValid from "./isRedemptionDatesValid"; import returnPeriodValue from "./returnPeriodValue"; -Yup.addMethod>>( +Yup.addMethod( Yup.array, "isRedemptionDatesValid", isRedemptionDatesValid @@ -17,7 +17,7 @@ Yup.addMethod>( "isRedemptionDatesValid", isRedemptionDatesValid ); -Yup.addMethod>>( +Yup.addMethod( Yup.array, "isOfferValidityDatesValid", isOfferValidityDatesValid @@ -27,11 +27,7 @@ Yup.addMethod>( "isOfferValidityDatesValid", isOfferValidityDatesValid ); -Yup.addMethod>>( - Yup.array, - "isItBeforeNow", - isItBeforeNow -); +Yup.addMethod(Yup.array, "isItBeforeNow", isItBeforeNow); Yup.addMethod( Yup.string, "disputePeriodValue", diff --git a/src/pages/chat/components/UploadForm/const.ts b/src/pages/chat/components/UploadForm/const.ts index 8f66f3e05..13a463747 100644 --- a/src/pages/chat/components/UploadForm/const.ts +++ b/src/pages/chat/components/UploadForm/const.ts @@ -21,8 +21,11 @@ export const validationOfFile = ({ supportedFormats?: string[]; }) => { const formats = supportedFormats || SUPPORTED_FILE_FORMATS; - return Yup.mixed() - .nullable(isOptional ? true : undefined) + let schema = Yup.mixed(); + if (!isOptional) { + schema = schema.nullable(); + } + return schema .test("numFiles", `Please upload one file`, (files: File[]) => { return isOptional ? true : !!(files || []).length; }) diff --git a/src/pages/create-product/CreateProductInner.tsx b/src/pages/create-product/CreateProductInner.tsx index ed983f29b..911eb4f79 100644 --- a/src/pages/create-product/CreateProductInner.tsx +++ b/src/pages/create-product/CreateProductInner.tsx @@ -553,7 +553,7 @@ function CreateProductInner({ for (const [index, variant] of Object.entries(variants)) { const productImages = productVariantsImages?.[Number(index)]?.productImages; - const { color, size } = variant; + const { color, size } = variant as { color: string; size: string }; const typeOptions = [ { type: TypeKeys.Size, diff --git a/src/pages/create-product/utils/buildCondition.ts b/src/pages/create-product/utils/buildCondition.ts index c014fa74e..c0b51167c 100644 --- a/src/pages/create-product/utils/buildCondition.ts +++ b/src/pages/create-product/utils/buildCondition.ts @@ -26,7 +26,7 @@ export const buildCondition = ( let threshold: string | undefined; let tokenId = partialTokenGating.tokenId || "0"; - let formatedValue = null; + let formatedValue: string | null = null; if (decimals && partialTokenGating.minBalance) { formatedValue = utils .parseUnits(partialTokenGating.minBalance, decimals) diff --git a/src/pages/create-product/utils/productDigital.ts b/src/pages/create-product/utils/productDigital.ts index 22d3f7689..8417b3aac 100644 --- a/src/pages/create-product/utils/productDigital.ts +++ b/src/pages/create-product/utils/productDigital.ts @@ -120,7 +120,7 @@ export function getDigitalMetadatas({ { traitType: "nft-type", - value: bundleItem.newNftType.value, + value: bundleItem.newNftType?.value || "", displayType: "NFT type" } ]; @@ -169,7 +169,7 @@ export function getDigitalMetadatas({ { traitType: "nft-type", - value: bundleItem.mintedNftType.value, + value: bundleItem.mintedNftType?.value || "", displayType: "NFT type" } ]; diff --git a/src/pages/dcl/DCLPage.tsx b/src/pages/dcl/DCLPage.tsx index 947c014a9..bbb8fa148 100644 --- a/src/pages/dcl/DCLPage.tsx +++ b/src/pages/dcl/DCLPage.tsx @@ -15,7 +15,7 @@ import { useKeepQueryParamsNavigate } from "../../lib/utils/hooks/useKeepQueryPa import { DetailsStep } from "./steps/details/DetailsStep"; import { ExecuteStep } from "./steps/execute/ExecuteStep"; import { DCLLayout } from "./styles"; -import { FormType, validationSchema } from "./validationSchema"; +import { FormType, LocationValues, validationSchema } from "./validationSchema"; const Background = styled.div` width: 100%; `; @@ -108,7 +108,7 @@ export default () => { > initialValues={{ - location: "" + location: "" as LocationValues.OwnLand | LocationValues.BosonLand }} validationSchema={validationSchema} onSubmit={() => { diff --git a/tsconfig.json b/tsconfig.json index 0e236ad97..a4652c530 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,6 +16,7 @@ "isolatedModules": true, "noEmit": true, "noImplicitThis": false, + "noImplicitAny": false, "jsx": "react-jsx", "paths": { "stream": ["./node_modules/readable-stream"],