any
type JS-032336
37export default UserFollowsModal
38
39const ModalItem = ({ name, avatar, setIsFollowsModal }: { name: string; avatar: string; setIsFollowsModal: any }) => {40 return (
41 <Box p='0.5rem' sx={{ width: '100%', display: 'flex', alignItems: 'center', borderBottom: '1px solid lightgray' }}>
42 <Link href={`/${name}`} passHref>
25 ? profile.followedBy.map((f: any) => (
26 <ModalItem avatar={f.avatar} name={f.name} key={f.id} setIsFollowsModal={setIsFollowsModal} />
27 ))
28 : profile.following.map((f: any) => (29 <ModalItem avatar={f.avatar} name={f.name} key={f.id} setIsFollowsModal={setIsFollowsModal} />
30 ))}
31 </Box>
22
23 <Box sx={{ width: '100%', maxHeight: '200px', overflowY: 'auto', display: 'flex', flexDirection: 'column' }}>
24 {isFollowsModal.type === 'followers'
25 ? profile.followedBy.map((f: any) => (26 <ModalItem avatar={f.avatar} name={f.name} key={f.id} setIsFollowsModal={setIsFollowsModal} />
27 ))
28 : profile.following.map((f: any) => (
3import React from 'react'
4import { ProfileProps } from '../../../types/app.types'
5
6const UserFollowsModal = ({ isFollowsModal, setIsFollowsModal, profile }: {isFollowsModal: any, setIsFollowsModal: any, profile: ProfileProps}) => { 7 return (
8 <Modal
9 opened={isFollowsModal.isOpen}
3import React from 'react'
4import { ProfileProps } from '../../../types/app.types'
5
6const UserFollowsModal = ({ isFollowsModal, setIsFollowsModal, profile }: {isFollowsModal: any, setIsFollowsModal: any, profile: ProfileProps}) => { 7 return (
8 <Modal
9 opened={isFollowsModal.isOpen}
The any
type can sometimes leak into your codebase. TypeScript compiler skips the type checking of the any
typed variables, so it creates a potential safety hole, and source of bugs in your codebase. We recommend using unknown
or never
type variable.
In TypeScript, every type is assignable to any
. This makes any
a top type (also known as a universal supertype) of the type system.
The any
type is essentially an escape hatch from the type system. As developers, this gives us a ton of freedom: TypeScript lets us perform any operation we want on values of type any
without having to perform any checking beforehand.
The developers should not assign any
typed value to variables and properties, which can be hard to pick up on, especially from the external library; instead, developers can use the never
or unknown
type variable.
const age: any = 'seventeen';
const ages: any[] = ['seventeen'];
const ages: Array<any> = ['seventeen'];
function greet(): any {}
function greet(): any[] {}
function greet(): Array<any> {}
function greet(): Array<Array<any>> {}
function greet(param: Array<any>): string {}
function greet(param: Array<any>): Array<any> {}
const age: number = 17;
const ages: number[] = [17];
const ages: Array<number> = [17];
function greet(): string {}
function greet(): string[] {}
function greet(): Array<string> {}
function greet(): Array<Array<string>> {}
function greet(param: Array<string>): string {}
function greet(param: Array<string>): Array<string> {}