typescript-satisfies-operator

Validate TypeScript values with the satisfies operator to preserve literal types.

280|36|Updated Jan 24, 2026
One-click install
npx skills add https://github.com/flpbalada/my-opencode-config --skill typescript-satisfies-operator
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-satisfies-operator
Source: https://github.com/flpbalada/my-opencode-config/tree/main/skills/typescript-satisfies-operator
Command: npx skills add https://github.com/flpbalada/my-opencode-config --skill typescript-satisfies-operator

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps TypeScript developers keep literal types when validating values, avoiding unwanted type widening that occurs with standard type annotations.

Core Features & Use Cases

  • Preserve literal types in object literals by using the satisfies operator for type validation without changing the inferred type.
  • Compare with colon annotations and as const to understand when to prefer each approach in real-world codebases.
  • Use case: when constructing a config object that should remain a narrow union type for precise autocomplete and safety.

Quick Start

Create a TypeScript snippet that demonstrates validating an object with satisfies to preserve a literal type and contrasts it with a colon-annotated version.

Frequently Asked Questions about typescript-satisfies-operator

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

FAQPage Schema
How do I preserve literal types in TypeScript without widening them?

To preserve literal types in TypeScript, use the satisfies operator to validate values against a type without altering the inferred literal union. This prevents unwanted type widening that typically occurs when using standard colon type annotations.

When should I use the satisfies operator instead of as const in TypeScript?

Use the satisfies operator in TypeScript when you need to validate configuration objects against a specific type while keeping exact literal inference for autocomplete. Unlike as const, it allows type checking without forcing readonly immutability.

Why does TypeScript widen my literal types when I use type annotations?

TypeScript widens literal types with type annotations because it allocates the declared type to the variable, discarding the exact literal union. Using the satisfies operator validates the value while retaining the precise literal type for safer static analysis.

Can I use satisfies to validate object literals in a TypeScript config?

Yes, you can use the satisfies operator to validate object literals in a TypeScript config. It checks the structure against an expected API type while preserving the narrow literal unions of the object's properties for precise autocomplete and safety.

Does the satisfies operator change runtime behavior in TypeScript?

No, the satisfies operator does not alter runtime behavior in TypeScript. It functions purely as a compile-time static analysis check, ensuring exact type inference and type safety without emitting any additional JavaScript code.