Do you avoid using “any”?
Rules to Better TypeScript|25449fba-5adb-4c5f-9269-e044b6384e9b
v1.0
Posted at
29/04/2016 5:41 AM by
Tiago Araujo
Rule Intro
TypeScript’s any keyword is a blessing and a curse. It is a type that can be anything, where every possible property and method exists and also returns any. It can be casted to and from anything and is how you tell the compiler to get out of your way.
However, it’s easy to use it as a crutch, and as a result, miss out on handy intellisense, refactoring support and compile-time safety – the main benefits of TypeScript!
Page Content
Aim to use any in the same way that you use the dynamic keyword in C# - that is, sparingly, and with careful consideration.

- Figure: Bad example – I can pass anything into this method, so I get bad output at run time (“undefined undefined”)

- Figure: Good example – using types means I get errors and intellisense support
{AEC54975-DDF2-421C-AE6D-0964F7E02B0B}
Do you feel this rule needs an update?