liberal-accept-strict-return

Liberalize API inputs while returning a single precise output format.

Updated Jul 17, 2017
One-click install
npx skills add https://github.com/luyi985/lyi-bash --skill liberal-accept-strict-return
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: liberal-accept-strict-return
Source: https://github.com/luyi985/lyi-bash/tree/main/ai/skills/liberal-accept-strict-return
Command: npx skills add https://github.com/luyi985/lyi-bash --skill liberal-accept-strict-return

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This pattern helps API designers and library authors balance flexibility with clarity by allowing broader input types while returning a fixed, precise output format. It applies Postel's Law to TypeScript and similar systems to improve usability without sacrificing downstream correctness.

Core Features & Use Cases

  • Accept multiple input formats or optional fields to make APIs easier to use.
  • Return a single, well-defined structure with concrete types to simplify consumption.
  • Use Case: Designing a function signature or API where callers may provide varied inputs but should receive a predictable result.

Quick Start

Broaden input types and constrain output to a single, precise format in your API design.

Frequently Asked Questions about liberal-accept-strict-return

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

FAQPage Schema
How do I design TypeScript APIs that accept flexible inputs but return strict output?

To design TypeScript APIs with flexible inputs and strict output, you broaden the accepted input types for multi-form or optional fields while constraining the return type to a single, precise canonical structure.

What does Postel's Law mean for TypeScript function signatures?

Postel's Law in TypeScript function signatures means accepting varied or optional input arguments from callers while returning a single, well-defined output structure to predictably simplify downstream data consumption.

When should I use liberal input and strict output patterns in API design?

Use liberal input and strict output patterns in API design when creating function signatures or data models where callers may provide varied inputs but require a predictable, canonical result format for downstream correctness.

Can I apply liberal input strict output patterns to TypeScript library design?

Yes, you can apply liberal input strict output patterns to TypeScript library design by allowing broader input types for ease of use while returning fixed, precise output formats to improve usability without sacrificing downstream correctness.

Why return a canonical output type from TypeScript functions with optional inputs?

Returning a canonical output type from TypeScript functions with optional inputs simplifies consumption by ensuring downstream code always receives a single, well-defined structure, preventing type checking errors and reducing complexity.

What are the limitations of accepting multi-form inputs in TypeScript APIs?

The main limitation of accepting multi-form inputs in TypeScript APIs is the increased internal complexity required to normalize varied formats into a single precise output, requiring clear separation between input flexibility and output specificity.