4 ms·
TypeScript itself has two types for this purpose: "any" and "unknown". "any" is the escape hatch and allows you to do anything with the variable. In essence it
by Ndymium 5y ago
TypeScript itself has two types for this purpose: "any" and "unknown".
"any" is the escape hatch and allows you to do anything with the variable. In essence it stops type checking entirely for that variable.
"unknown" takes the opposite approach and doesn't let you do anything with the variable value (other than pass it along to other "unknown" accepting variables/functions) until you have asserted its actual type with type guards.