Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove use of any #1657

Merged
merged 8 commits into from
Jan 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions apps/web/src/components/Comment/Feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import InfiniteLoader from '@components/UI/InfiniteLoader';
import { CollectionIcon } from '@heroicons/react/outline';
import { t } from '@lingui/macro';
import { SCROLL_THRESHOLD } from 'data/constants';
import type { Comment, Publication } from 'lens';
import type { Comment, Publication, PublicationsQueryRequest } from 'lens';
import { CustomFiltersTypes, useCommentFeedQuery } from 'lens';
import type { FC } from 'react';
import InfiniteScroll from 'react-infinite-scroll-component';
Expand All @@ -28,7 +28,11 @@ const Feed: FC<Props> = ({ publication }) => {
const txnQueue = useTransactionPersistStore((state) => state.txnQueue);

// Variables
const request = { commentsOf: publicationId, customFilters: [CustomFiltersTypes.Gardeners], limit: 10 };
const request: PublicationsQueryRequest = {
commentsOf: publicationId,
customFilters: [CustomFiltersTypes.Gardeners],
limit: 10
};
const reactionRequest = currentProfile ? { profileId: currentProfile?.id } : null;
const profileId = currentProfile?.id ?? null;

Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/components/Composer/Actions/Attachment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const Attachment: FC = () => {

useOnClickOutside(dropdownRef, () => setShowMenu(false));

const hasVideos = (files: any) => {
const hasVideos = (files: FileList) => {
let videos = 0;
let images = 0;

Expand All @@ -53,7 +53,7 @@ const Attachment: FC = () => {
return false;
};

const isTypeAllowed = (files: any) => {
const isTypeAllowed = (files: FileList) => {
for (const file of files) {
if (ALLOWED_MEDIA_TYPES.includes(file.type)) {
return true;
Expand All @@ -63,7 +63,7 @@ const Attachment: FC = () => {
return false;
};

const isImageType = (files: any) => {
const isImageType = (files: FileList) => {
for (const file of files) {
if (!ALLOWED_IMAGE_TYPES.includes(file.type)) {
return false;
Expand All @@ -85,7 +85,7 @@ const Attachment: FC = () => {
}

// Type check
if (isTypeAllowed(files)) {
if (isTypeAllowed(files as FileList)) {
await handleUploadAttachments(files);
evt.target.value = '';
} else {
Expand Down
7 changes: 5 additions & 2 deletions apps/web/src/components/Composer/NewPublication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import type { IGif } from '@giphy/js-types';
import { ChatAlt2Icon, PencilAltIcon } from '@heroicons/react/outline';
import type { CollectCondition, EncryptedMetadata, FollowCondition } from '@lens-protocol/sdk-gated';
import { LensGatedSDK } from '@lens-protocol/sdk-gated';
import type { AccessConditionOutput } from '@lens-protocol/sdk-gated/dist/graphql/types';
import type {
AccessConditionOutput,
CreatePublicPostRequest
} from '@lens-protocol/sdk-gated/dist/graphql/types';
import { $convertFromMarkdownString } from '@lexical/markdown';
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
import { Analytics } from '@lib/analytics';
Expand Down Expand Up @@ -464,7 +467,7 @@ const NewPublication: FC<Props> = ({ publication }) => {
arweaveId = await createMetadata(metadata);
}

const request = {
const request: CreatePublicPostRequest | CreatePublicCommentRequest = {
profileId: currentProfile?.id,
contentURI: `https://arweave.net/${arweaveId}`,
...(isComment && {
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/components/Explore/Feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ import InfiniteLoader from '@components/UI/InfiniteLoader';
import { CollectionIcon } from '@heroicons/react/outline';
import { t } from '@lingui/macro';
import { SCROLL_THRESHOLD } from 'data/constants';
import type { Publication } from 'lens';
import type { ExplorePublicationRequest, Publication, PublicationMainFocus } from 'lens';
import { CustomFiltersTypes, PublicationSortCriteria, useExploreFeedQuery } from 'lens';
import type { FC } from 'react';
import InfiniteScroll from 'react-infinite-scroll-component';
import { useAppStore } from 'src/store/app';

interface Props {
focus?: any;
focus?: PublicationMainFocus;
feedType?: PublicationSortCriteria;
}

const Feed: FC<Props> = ({ focus, feedType = PublicationSortCriteria.CuratedProfiles }) => {
const currentProfile = useAppStore((state) => state.currentProfile);

// Variables
const request = {
const request: ExplorePublicationRequest = {
sortCriteria: feedType,
noRandomize: feedType === 'LATEST',
customFilters: [CustomFiltersTypes.Gardeners],
metadata: focus ? { mainContentFocus: focus } : null,
metadata: focus ? { mainContentFocus: [focus] } : null,
limit: 10
};
const reactionRequest = currentProfile ? { profileId: currentProfile?.id } : null;
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/components/Explore/FeedType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import { PublicationMainFocus } from 'lens';
import type { Dispatch, FC } from 'react';

interface Props {
setFocus: Dispatch<any>;
focus: string;
setFocus: Dispatch<PublicationMainFocus>;
focus?: PublicationMainFocus;
}

const FeedType: FC<Props> = ({ setFocus, focus }) => {
interface FeedLinkProps {
name: string;
type?: string;
type?: PublicationMainFocus;
}

const FeedLink: FC<FeedLinkProps> = ({ name, type }) => (
<button
type="button"
onClick={() => {
setFocus(type);
setFocus(type as PublicationMainFocus);
Analytics.track(`select_${(type ?? 'all_posts')?.toLowerCase()}_filter_in_explore`);
}}
className={clsx(
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/components/Explore/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import isFeatureEnabled from '@lib/isFeatureEnabled';
import { t } from '@lingui/macro';
import clsx from 'clsx';
import { APP_NAME } from 'data/constants';
import type { PublicationMainFocus } from 'lens';
import { PublicationSortCriteria } from 'lens';
import type { NextPage } from 'next';
import { useRouter } from 'next/router';
Expand All @@ -20,7 +21,7 @@ import FeedType from './FeedType';

const Explore: NextPage = () => {
const currentProfile = useAppStore((state) => state.currentProfile);
const [focus, setFocus] = useState<any>();
const [focus, setFocus] = useState<PublicationMainFocus>();
const router = useRouter();

const tabs = [
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Home/Highlights.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import InfiniteLoader from '@components/UI/InfiniteLoader';
import { CollectionIcon } from '@heroicons/react/outline';
import { t } from '@lingui/macro';
import { SCROLL_THRESHOLD } from 'data/constants';
import type { Publication } from 'lens';
import type { FeedHighlightsRequest, Publication } from 'lens';
import { useFeedHighlightsQuery } from 'lens';
import type { FC } from 'react';
import InfiniteScroll from 'react-infinite-scroll-component';
Expand All @@ -20,7 +20,7 @@ const Highlights: FC = () => {
const txnQueue = useTransactionPersistStore((state) => state.txnQueue);

// Variables
const request = { profileId: currentProfile?.id, limit: 10 };
const request: FeedHighlightsRequest = { profileId: currentProfile?.id, limit: 10 };
const reactionRequest = currentProfile ? { profileId: currentProfile?.id } : null;
const profileId = currentProfile?.id ?? null;

Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Home/SeeThroughLens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import formatHandle from '@lib/formatHandle';
import getAvatar from '@lib/getAvatar';
import { t, Trans } from '@lingui/macro';
import clsx from 'clsx';
import type { FeedItem, Profile, ProfileSearchResult } from 'lens';
import type { FeedItem, FeedRequest, Profile, ProfileSearchResult } from 'lens';
import {
CustomFiltersTypes,
SearchRequestTypes,
Expand Down Expand Up @@ -49,7 +49,7 @@ const SeeThroughLens: FC = () => {
};

const profile = seeThroughProfile ?? currentProfile;
const request = { profileId: profile?.id, limit: 50 };
const request: FeedRequest = { profileId: profile?.id, limit: 50 };

const [searchUsers, { data: searchUsersData, loading: searchUsersLoading }] = useSearchProfilesLazyQuery();

Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Home/Timeline/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import InfiniteLoader from '@components/UI/InfiniteLoader';
import { CollectionIcon } from '@heroicons/react/outline';
import { t } from '@lingui/macro';
import { SCROLL_THRESHOLD } from 'data/constants';
import type { FeedItem, Publication } from 'lens';
import type { FeedItem, FeedRequest, Publication } from 'lens';
import { FeedEventItemType, useTimelineQuery } from 'lens';
import type { FC } from 'react';
import InfiniteScroll from 'react-infinite-scroll-component';
Expand Down Expand Up @@ -41,7 +41,7 @@ const Timeline: FC = () => {

// Variables
const profileId = seeThroughProfile?.id ?? currentProfile?.id;
const request = { profileId, limit: 50, feedEventItemTypes: getFeedEventItems() };
const request: FeedRequest = { profileId, limit: 50, feedEventItemTypes: getFeedEventItems() };
const reactionRequest = currentProfile ? { profileId } : null;

const { data, loading, error, fetchMore } = useTimelineQuery({
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Mod/Feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import InfiniteLoader from '@components/UI/InfiniteLoader';
import { CollectionIcon } from '@heroicons/react/outline';
import { t } from '@lingui/macro';
import { SCROLL_THRESHOLD } from 'data/constants';
import type { Publication } from 'lens';
import type { ExplorePublicationRequest, Publication } from 'lens';
import { PublicationSortCriteria, PublicationTypes, useExploreFeedQuery } from 'lens';
import type { FC } from 'react';
import InfiniteScroll from 'react-infinite-scroll-component';
Expand All @@ -17,7 +17,7 @@ const Feed: FC = () => {
const currentProfile = useAppStore((state) => state.currentProfile);

// Variables
const request = {
const request: ExplorePublicationRequest = {
sortCriteria: PublicationSortCriteria.Latest,
publicationTypes: [PublicationTypes.Post, PublicationTypes.Comment],
noRandomize: true,
Expand Down
5 changes: 3 additions & 2 deletions apps/web/src/components/Notification/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import type {
NewFollowerNotification,
NewMentionNotification,
NewMirrorNotification,
NewReactionNotification
NewReactionNotification,
NotificationRequest
} from 'lens';
import { CustomFiltersTypes, NotificationTypes, useNotificationsQuery } from 'lens';
import type { FC } from 'react';
Expand Down Expand Up @@ -51,7 +52,7 @@ const List: FC<Props> = ({ feedType }) => {
};

// Variables
const request = {
const request: NotificationRequest = {
profileId: currentProfile?.id,
customFilters: [CustomFiltersTypes.Gardeners],
notificationTypes: getNotificationType(),
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Profile/Feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CollectionIcon } from '@heroicons/react/outline';
import formatHandle from '@lib/formatHandle';
import { t } from '@lingui/macro';
import { SCROLL_THRESHOLD } from 'data/constants';
import type { Profile, Publication } from 'lens';
import type { Profile, Publication, PublicationsQueryRequest } from 'lens';
import { PublicationMainFocus, PublicationTypes, useProfileFeedQuery } from 'lens';
import type { FC } from 'react';
import InfiniteScroll from 'react-infinite-scroll-component';
Expand Down Expand Up @@ -61,7 +61,7 @@ const Feed: FC<Props> = ({ profile, type }) => {
mainContentFocus: getMediaFilters()
}
: null;
const request = {
const request: PublicationsQueryRequest = {
publicationTypes,
metadata,
...(type !== ProfileFeedType.Collects ? { profileId: profile?.id } : { collectedBy: profile?.ownedBy }),
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Profile/Followers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { UsersIcon } from '@heroicons/react/outline';
import formatHandle from '@lib/formatHandle';
import { t, Trans } from '@lingui/macro';
import { SCROLL_THRESHOLD } from 'data/constants';
import type { Profile, Wallet } from 'lens';
import type { FollowersRequest, Profile, Wallet } from 'lens';
import { useFollowersQuery } from 'lens';
import type { FC } from 'react';
import InfiniteScroll from 'react-infinite-scroll-component';
Expand All @@ -20,7 +20,7 @@ interface Props {

const Followers: FC<Props> = ({ profile }) => {
// Variables
const request = { profileId: profile?.id, limit: 10 };
const request: FollowersRequest = { profileId: profile?.id, limit: 10 };

const { data, loading, error, fetchMore } = useFollowersQuery({
variables: { request },
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Profile/Following.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { UsersIcon } from '@heroicons/react/outline';
import formatHandle from '@lib/formatHandle';
import { t, Trans } from '@lingui/macro';
import { SCROLL_THRESHOLD } from 'data/constants';
import type { Profile } from 'lens';
import type { FollowingRequest, Profile } from 'lens';
import { useFollowingQuery } from 'lens';
import type { FC } from 'react';
import InfiniteScroll from 'react-infinite-scroll-component';
Expand All @@ -20,7 +20,7 @@ interface Props {

const Following: FC<Props> = ({ profile, onProfileSelected }) => {
// Variables
const request = { address: profile?.ownedBy, limit: 10 };
const request: FollowingRequest = { address: profile?.ownedBy, limit: 10 };

const { data, loading, error, fetchMore } = useFollowingQuery({
variables: { request },
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Profile/MutualFollowers/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ErrorMessage } from '@components/UI/ErrorMessage';
import InfiniteLoader from '@components/UI/InfiniteLoader';
import { t } from '@lingui/macro';
import { SCROLL_THRESHOLD } from 'data/constants';
import type { Profile } from 'lens';
import type { MutualFollowersProfilesQueryRequest, Profile } from 'lens';
import { useMutualFollowersListQuery } from 'lens';
import type { FC } from 'react';
import InfiniteScroll from 'react-infinite-scroll-component';
Expand All @@ -19,7 +19,7 @@ const MutualFollowersList: FC<Props> = ({ profileId }) => {
const currentProfile = useAppStore((state) => state.currentProfile);

// Variables
const request = {
const request: MutualFollowersProfilesQueryRequest = {
viewingProfileId: profileId,
yourProfileId: currentProfile?.id,
limit: 10
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Profile/NFTFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { CollectionIcon } from '@heroicons/react/outline';
import formatHandle from '@lib/formatHandle';
import { t, Trans } from '@lingui/macro';
import { SCROLL_THRESHOLD } from 'data/constants';
import type { Nft, Profile } from 'lens';
import type { Nft, NfTsRequest, Profile } from 'lens';
import { useNftFeedQuery } from 'lens';
import type { FC } from 'react';
import InfiniteScroll from 'react-infinite-scroll-component';
Expand All @@ -20,7 +20,7 @@ interface Props {

const NFTFeed: FC<Props> = ({ profile }) => {
// Variables
const request = {
const request: NfTsRequest = {
chainIds: [CHAIN_ID, mainnet.id],
ownerAddress: profile?.ownedBy,
limit: 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import getEnvConfig from 'data/utils/getEnvConfig';
import dayjs from 'dayjs';
import type { BigNumber } from 'ethers';
import { defaultAbiCoder } from 'ethers/lib/utils';
import type { ElectedMirror, Publication } from 'lens';
import type { ApprovedAllowanceAmount, ElectedMirror, Publication } from 'lens';
import {
CollectModules,
useApprovedModuleAllowanceAmountQuery,
Expand Down Expand Up @@ -426,7 +426,7 @@ const CollectModule: FC<Props> = ({ count, setCount, publication, electedMirror
) : (
<AllowanceButton
title="Allow collect module"
module={allowanceData?.approvedModuleAllowanceAmount[0]}
module={allowanceData?.approvedModuleAllowanceAmount[0] as ApprovedAllowanceAmount}
allowed={allowed}
setAllowed={setAllowed}
/>
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Publication/Actions/Menu/Delete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import clsx from 'clsx';
import type { Publication } from 'lens';
import { useHidePublicationMutation } from 'lens';
import { useRouter } from 'next/router';
import type { FC } from 'react';
import type { FC, MouseEvent } from 'react';
import { PUBLICATION } from 'src/tracking';

interface Props {
Expand All @@ -30,7 +30,7 @@ const Delete: FC<Props> = ({ publication }) => {
'block px-4 py-1.5 text-sm text-red-500 m-2 rounded-lg cursor-pointer'
)
}
onClick={(event: any) => {
onClick={(event: MouseEvent<HTMLDivElement>) => {
event.stopPropagation();
if (confirm('Are you sure you want to delete?')) {
hidePost({
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Publication/Actions/Menu/Embed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CodeIcon } from '@heroicons/react/outline';
import { Analytics } from '@lib/analytics';
import clsx from 'clsx';
import type { Publication } from 'lens';
import type { FC } from 'react';
import type { FC, MouseEvent } from 'react';
import { PUBLICATION } from 'src/tracking';

interface Props {
Expand All @@ -17,7 +17,7 @@ const Embed: FC<Props> = ({ publication }) => {
className={({ active }) =>
clsx({ 'dropdown-active': active }, 'block px-4 py-1.5 text-sm m-2 rounded-lg cursor-pointer')
}
onClick={(event: any) => {
onClick={(event: MouseEvent<HTMLAnchorElement>) => {
event.stopPropagation();
Analytics.track(PUBLICATION.EMBED);
}}
Expand Down
Loading