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.

GroupBasic Types
KindType
Strict modeNot 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

noImplicitAnyCompiler 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.
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.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏