Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use TypeScript’s satisfies when you want to check that a value fits a type without widening away useful details inferred from that value. Use as only when you have a specific reason to tell the compiler to treat an expression as another type—and understand that this assertion does not validate the value at runtime.

What is the difference between satisfies and as?

TypeScript introduced satisfies in version 4.9. It checks an expression against a target type while preserving the expression’s resulting inferred type. A type assertion with as, by contrast, asks TypeScript to treat an expression as a specified type. Neither construct performs runtime validation.

Construct What it tells TypeScript Effect on the expression
satisfies T Check that the expression is compatible with T. Retains the expression’s inferred type.
const value: T Declare the variable with type T. Uses the declared type at later use sites, which may be broader than the inferred details of the initializer.
value as T Assert that the expression should be treated as type T. Changes the type TypeScript uses for that expression; it does not prove the value has that shape.

The official TypeScript 4.9 release notes describe satisfies this way: “The new satisfies operator lets us validate that the type of an expression matches some type, without changing the resulting type of that expression.” Here, “validate” means a compile-time type check, not inspection of a value while the program runs.

Why satisfies helps with object literals

Suppose a palette must have exactly the expected color keys, but each property should keep its own useful inferred type. The release notes use this example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
type Colors = "red" | "green" | "blue";
type Palette = Record<Colors, string | [number, number, number]>;

const palette = {
  red: [255, 0, 0],
  green: "#00ff00",
  bleu: [0, 0, 255], // Error: "bleu" is not a valid key
} satisfies Palette;

palette.green.toUpperCase();

The misspelled bleu key is caught because the object is checked against Palette. The check does not replace palette with the broad Palette type. TypeScript retains that green is a string, so the string method remains available.

This is useful for configuration objects, lookup tables, and other literals where you want a known shape checked but still want precise information about individual properties. A type annotation can also check an initializer, but the declared variable type may be broader at later use sites. Choose the annotation when that declared interface is what you want to work with; choose satisfies when keeping narrower inferred details matters.

Rank #2
TypeScript Programming Language - Software Engineer & Coder T-Shirt
  • TypeScript implements a superset of syntax for strictly typed development, facilitating deep static analysis and enhanced development environment integration. The compiler translates source into standard script formats, ensuring parity across any runtime.
  • TypeScript is ideal for front-end developers, full-stack engineers, and software architects who build large-scale web applications. It serves those looking to improve code excellence, reduce bugs through static checking, and maintain complex projects more.
  • Lightweight, Classic fit, Double-needle sleeve and bottom hem

When is as justified?

An assertion can be appropriate when you have information that TypeScript cannot infer from the code. For example, a programmer may know from the page’s markup that a particular DOM query selects a div:

const panel = document.querySelector("#panel") as HTMLDivElement;

The assertion is only as trustworthy as that knowledge. If the selector might match a different element—or no element—the assertion does not make the result a real HTMLDivElement or prevent a runtime failure. The related article’s example is discussed in “You Are Lying to Your Compiler. Use ‘satisfies’ Instead of ‘as’”; the compiler’s role and the limits of assertions are also covered in the TypeScript Handbook’s type assertions section.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If the result is uncertain, handle that uncertainty with a runtime check rather than using an assertion as a substitute. For example, check that a query returned an element and verify its tag before relying on element-specific behavior.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What neither operator does for external data

A JSON response, network payload, or other runtime input is not made safe by writing payload as SomeType. The assertion changes what TypeScript assumes; it does not inspect the incoming data. Likewise, satisfies checks types available to the compiler and is not a runtime schema validator. For untrusted values, parse or validate the data at runtime before using it as a trusted type.

A quick choice guide

  • Use satisfies for a typed object literal when you want compatibility checking and useful property-level inference.
  • Use a type annotation when the variable’s declared interface is the intended type for subsequent code.
  • Use as selectively when external knowledge justifies an assertion that the compiler cannot establish.
  • Use runtime validation when a value comes from an untrusted source; neither satisfies nor as checks that value while the program runs.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.