any The any Type
Last updated: 2026-10-22
any The any Type
any means "opt out of type checking": anything is assignable to it and it is assignable to anything. Useful for JS migration or truly unknown data, but the compiler stops checking everything downstream.
| Group | Basic Types |
|---|---|
| Kind | Type |
| Strict mode | Not required |
ℹ️ Info The editor transpiles TypeScript to JavaScript and runs it (no type checking); see each example's Output for type-check results.
📝 Syntax
let data: any = JSON.parse(text);
data.whatever.method(); // no compile error
⚙️ Parameters
| noImplicitAny | Compiler option that flags implicit anys (no annotation and no inference); keep it on |
|---|
Returns:None — any is an annotation whose effect is precisely disabling type-level checks.
▶ Example
Edit the code below and click Try it to see the transpiled result:
Output:
4 Ada
(Runtime output after transpilation; a typo like payload.lvel would not fail the compile — you would get NaN at runtime)
💡 Notes
⚠️ Note any is contagious: every expression it touches loses checking, so typos and null errors surface only at runtime.
💡 Tip Receive unknown data as unknown and narrow it — far safer than any (see the unknown entry for the comparison).
ℹ️ Info Explicit any differs from implicit any (no annotation, no inference); noImplicitAny flags all implicit cases.
🏷️ Related Basic Types
💡 Related cases
More cases coming soon.
📚 Related tutorials
❓ FAQ
Q any vs unknown?
A Both accept any value; the difference is usage — any allows any operation directly, unknown must be narrowed or asserted first. unknown is the safe any.
Q When is any unavoidable?
A Rarely truly unavoidable: temporary use during migration or with untyped libraries is fine, but add types (or switch to unknown) immediately. New anys in mainline code deserve review pushback.
Q How to limit any usage across a team?
A Triple: strict in tsconfig (includes noImplicitAny), ESLint's @typescript-eslint/no-explicit-any, and treating new anys as review flags.