Avoid using any at all costs! You will benefit from specifying types more precisely, and if you happen not to know the exact type, you can use unknown type – which is similar to any, but it doesn't allow code to escape the TypeScript type system. More on that: stackoverflow.com/questions/514398...
Never-ever use Function and object types. It's the same thing as with any: you lose all type safety this way. For your example it's better to use React.EventHandler<T> type and its specializations like MouseEventHandler, PointerEventHandler and so on, or specify function signatures explicitly:
If you want to dive deeper in type-safe TypeScript development, please check out my article (it's currently on Medium, but if an interest arise, I'll re-post it here): levelup.gitconnected.com/typesafe-...
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Some more tips:
Avoid using
any
at all costs! You will benefit from specifying types more precisely, and if you happen not to know the exact type, you can useunknown
type – which is similar toany
, but it doesn't allow code to escape the TypeScript type system. More on that: stackoverflow.com/questions/514398...Never-ever use
Function
andobject
types. It's the same thing as withany
: you lose all type safety this way. For your example it's better to useReact.EventHandler<T>
type and its specializations likeMouseEventHandler
,PointerEventHandler
and so on, or specify function signatures explicitly:If you want to dive deeper in type-safe TypeScript development, please check out my article (it's currently on Medium, but if an interest arise, I'll re-post it here): levelup.gitconnected.com/typesafe-...