A type assertion (`as T`) overrides TypeScript's inferred type without changing runtime behaviour. It's a compile-time-only tool, unlike a runtime type conversion.
ts
const input = document_result as unknown; // stand-in for any external value
const amount = input as number;
const el = fetchSomething() as { value: number };Assertions are only allowed between compatible types (you can't assert `string` to `number` directly; you'd go through `unknown` first). They should be used sparingly — prefer narrowing with `if` checks or validating input at runtime, since `as` provides no actual safety, only a compiler-level promise.