typescript-satisfies-operator

Guides correct usage of TypeScript's satisfies operator versus type annotations for literal type preservation.

Updated Apr 29, 2026
One-click install
npx skills add https://github.com/dev-khoi/AURA-conHack-2026 --skill typescript-satisfies-operator-dev-khoi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: typescript-satisfies-operator
Source: https://github.com/dev-khoi/AURA-conHack-2026/tree/main/.opencode/skills/typescript-satisfies-operator
Command: npx skills add https://github.com/dev-khoi/AURA-conHack-2026 --skill typescript-satisfies-operator-dev-khoi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? TypeScript developers often lose narrow literal types when using colon type annotations, causing inference issues, missed typos in object keys, and broken autocomplete. This Skill clarifies when to use satisfies, colon annotations, as const, or plain inference so values are validated without widening their types. ## Core Features & Use Cases - Annotation Decision Guidance: Explains the difference between : Type (type wins), satisfies Type (value wins), as Type (escape hatch), and plain inference, with a rule-of-thumb table. - Object Validation with Preserved Literals: Shows how satisfies catches typos and missing keys in records while keeping each property's narrow inferred type. - Real-World Patterns: Covers as const satisfies for immutable config maps, exhaustive Record checks over union types, event handler maps, and locale/config validation. - Use Case: When defining a route map or status label record, apply as const satisfies Record<Status, string> so TypeScript errors if a key is missing while each value keeps its literal type. ## Quick Start Ask the AI to review your TypeScript object definitions and decide whether satisfies, a colon annotation, or as const satisfies is the right choice for preserving literal types.

Frequently Asked Questions about typescript-satisfies-operator

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
When should I use satisfies instead of a type annotation in TypeScript?▼

Use satisfies when you want validation against a type while keeping the expression's narrow inferred type. Use a colon annotation when you need the wider type, such as reassigning the variable later with other values of the union.

What is the difference between satisfies and as in TypeScript?▼

satisfies validates that a value matches a type without changing inference, while as is a type assertion that tells TypeScript to trust you and can lie about the actual type. Prefer satisfies; treat as as a sparing escape hatch.

How do I validate an object while keeping literal types in TypeScript?▼

Append satisfies YourType after the object literal, optionally combined with as const. This catches typos and missing keys while each property keeps its narrow literal type instead of widening to the annotated type.

Does satisfies work with as const for readonly config objects?▼

Yes, as const satisfies Record<K, V> makes all properties readonly literal types while still validating the shape. TypeScript errors if a required key is missing, and values keep their exact literal types.

Why does my variable lose its literal type after a colon annotation?▼

A colon annotation widens the value to the annotated type, so const url: RoutingPathname = "/products" is typed as the full union, not "/products". Use satisfies to validate while preserving the literal type.