any
type JS-0323 2 * @param param0
3 * @returns
4 */
5export function ItemsQuantity({ item }: { item: any }): JSX.Element { 6 return (
7 <div className="text-zinc-900">
8 <p className="sm:text-lg md:text-xl lg:text-2xl xl:text-3xl">
8function Items({ items, onDelete, onEdit }: any): JSX.Element {
9 return (
10 <>
11 {items.map((item: { id: any }): JSX.Element => (12 <GroceryItem
13 item={item}
14 key={item.id}
5 * @param param0
6 * @returns
7 */
8function Items({ items, onDelete, onEdit }: any): JSX.Element { 9 return (
10 <>
11 {items.map((item: { id: any }): JSX.Element => (
5 * @param param0
6 * @returns
7 */
8function Header({ showForm, changeTextAndColor }: any): JSX.Element { 9 return (
10 <header className="flex items-center justify-between mb-4 header">
11 <h2 className="font-serif text-xl app-header sm:text-2xl md:text-3xl lg:text-4xl xl:text-5xl">
2 * @param
3 * @returns
4 */
5function Button({ color, text, onClick }: any): JSX.Element { 6 return (
7 <button
8 type="button"
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> {}