On this page
any
Prev: `infer` | Up: builtins | Next: `enum`
Rel: unknown, builtins, Structural Typing & Narrowing
Ref: TypeScript Docs — any
Tags: #public #web #typescript #builtins #tier/legacy
Syntax & Overview
let x: any;
Disables type checking completely for x and silently propagates infectiously to expressions derived from it.
Legacy / Avoid: Prefer unknown in all new code.
Notes & Pitfalls
- Turns off type checking completely: Spreads silently into downstream code—prefer
unknownfor external/unvalidated data so callers must narrow first. - Enable
noImplicitAnyintsconfig.json(included in"strict": true).
Example
// Prefer `unknown` over `any` at API boundaries:
function parseLength(raw: unknown): number {
if (typeof raw === "string") return raw.length;
throw new Error("Expected string");
}
Linked from
Related notes
- tuts/typescript/builtins/enum Linked here; links to this page; shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins/infer Linked here; links to this page; shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins Linked here; links to this page; shared tags: #builtins, #typescript, #web
- tuts/typescript/builtins/unknown Linked here; shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/type_system/structural_typing_and_narrowing Linked here; shared tags: #typescript, #web
- tuts/typescript/builtins/as_const shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins/asserts shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins/is shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins/keyof shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins/namespace shared tags: #builtins, #tier, #typescript, #web