31 formData.append('email', userInfo.email)
32 formData.append('password', userInfo.password)
33 formData.append('pfp', userInfo.pfp)
34 await createUser(formData).then((res: any) => {35 localStorage.setItem('token', res.data.token)
36 dispatch(changeAuthStatus(true))
37 window.location.reload()
16
17 const submitHandler = async (e: any) => {
18 await signIn(userInfo)
19 .then((res: any) => {20 localStorage.setItem('token', res.data.token)
21 dispatch(changeAuthStatus(true))
22 window.location.reload()
14 password: '',
15 })
16
17 const submitHandler = async (e: any) => {18 await signIn(userInfo)
19 .then((res: any) => {
20 localStorage.setItem('token', res.data.token)
10 Changelogs: { icon: '🔑', color: '#FF4D00' },
11 Questions: { icon: '🤨', color: '#FF4D00' },
12 }
13 const handleChannelChange = (e: any) => {14 e.preventDefault()
15 }
16 return (
70 const [msg, setMsg] = useState<string>('')
71 const [sysMsg, setSysMsg] = useState<any>(null)
72 const msgListDiv = useRef<HTMLDivElement>(null)
73 const sendMsg = (e: any) => { 74 e.preventDefault()
75 if (msg.trim() !== '') {
76 sendMessage(msg)
68 }
69 }, [data])
70 const [msg, setMsg] = useState<string>('')
71 const [sysMsg, setSysMsg] = useState<any>(null) 72 const msgListDiv = useRef<HTMLDivElement>(null)
73 const sendMsg = (e: any) => {
74 e.preventDefault()
53 },
54 retryOnError: true,
55 })
56 const [msgs, setMsgs] = useState<any>([]) 57 useEffect(() => {
58 getMessages({
59 productId,
11 owner,
12}: {
13 show: boolean
14 setShow: any 15 productName: string
16 owner: boolean
17}) {
9 productIcon,
10}: {
11 show: boolean
12 setShow: any13 productName: string
14 productIcon: string | null
15}) {
221 productName: string
222 productID: number
223 isShown: boolean
224 setIsShown: any225}) => {
226 const closeHandler = () => {
227 setIsShown(false)
19 const [trigger, result, lastPromiseInfo] = useLazyGetUserInfoQuery()
20 const [updateUser, updateUserReqInfo] = useUpdateUserMutation()
21 const [pfp, setPfp] = useState<File>()
22 const updateHandler = async (e: any) => { 23 e.preventDefault()
24 if (userInfo) {
25 const formData = new FormData()
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.
Bad Practice
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> {}
Recommended
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> {}