25}
26
27interface CreatePostArgs {
28 post: any 29 productName: string
30 channel: string
31}
87 body: userInfo,
88 }),
89 }),
90 createUser: builder.mutation<void, any>({ 91 query: (user) => ({
92 url: 'users/create',
93 method: 'POST',
259 query: ({ productId, lastId }) =>
260 `products/messages/${productId}/${lastId || 0}`,
261 }),
262 updateUser: builder.mutation<void, any>({263 query: (data: any) => ({
264 url: `users/update`,
265 method: 'PATCH',
260 `products/messages/${productId}/${lastId || 0}`,
261 }),
262 updateUser: builder.mutation<void, any>({
263 query: (data: any) => ({264 url: `users/update`,
265 method: 'PATCH',
266 body: data,
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);
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,
14 useCreateCommentMutation()
15 const [shoErr, setShowErr] = useState(false)
16 const router = useRouter()
17 const submitHandler = async (e: any) => {18 e.preventDefault()
19 if (!comment) {
20 setShowErr(true)
10export interface fieldValues {
11 name: 'working-on' | 'done' | 'under-review'
12 color: string
13 icon: any 14}
15type fields = Record<string, fieldValues>
16export default function AddPostToBoard({
11 owner,
12}: {
13 show: boolean;
14 setShow: any; 15 productName: string;
16 owner: boolean;
17}) {
11}: {
12 name: string
13 bgcolor: string
14 posts: any15 ref: any
16 icon: any
17 setPosts: any
12 name: string
13 bgcolor: string
14 posts: any
15 ref: any16 icon: any
17 setPosts: any
18 dropInfo: any
13 bgcolor: string
14 posts: any
15 ref: any
16 icon: any17 setPosts: any
18 dropInfo: any
19 productId: number
14 posts: any
15 ref: any
16 icon: any
17 setPosts: any18 dropInfo: any
19 productId: number
20}) {
15 ref: any
16 icon: any
17 setPosts: any
18 dropInfo: any19 productId: number
20}) {
21 return (
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();
217 productName: string;
218 productID: number;
219 isShown: boolean;
220 setIsShown: any;221}) => {
222 const closeHandler = () => {
223 setIsShown(false);
21 </Provider>
22 )
23}
24const EmptyLayout = ({ children }: { children: any }) => <>{children}</>25const DefaultLayout = ({ children }: { children: any }) => {
26 const { data, isLoading, error } = useGetUserInfoQuery()
27 return (
22 )
23}
24const EmptyLayout = ({ children }: { children: any }) => <>{children}</>
25const DefaultLayout = ({ children }: { children: any }) => {26 const { data, isLoading, error } = useGetUserInfoQuery()
27 return (
28 <>
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> {}