currying-inference

Introduce explicit TypeScript inference sites via currying and builder patterns.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Use when generic types aren't inferred. Use when builder patterns need better types. Use when creating new inference sites.

Core Features & Use Cases

  • Currying to create new inference sites for generic parameters
  • Builder-pattern-friendly APIs to propagate type information
  • Factory helpers and type-safe APIs to improve inference in common workflows

Quick Start

Define a curried or builder-based API to introduce inference points and then instantiate with a concrete type and endpoint.

Frequently Asked Questions about currying-inference

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

FAQPage Schema
Why does TypeScript fail to infer generic types in my chained API calls?

TypeScript generic inference fails in chained API calls when there are insufficient inference sites for the compiler to bind types. Introducing currying or builder patterns creates explicit inference points, allowing the type checker to correctly propagate type information.

How do I use currying to fix generic type inference gaps in TypeScript?

To fix generic type inference gaps using currying, define a curried helper that accepts a concrete type in the first parameter, creating an explicit inference site. This allows the returned function to yield correctly typed results with strong type safety.

What is the best way to propagate type information in a builder pattern API?

The best way to propagate type information in a builder pattern API is to implement builder methods that expose specific inference points. This ensures strong type safety and maintainable inference progress throughout the chained construction process.

Can I use factory functions to improve TypeScript type safety in existing APIs?

Yes, you can use factory helpers to improve TypeScript type safety in existing APIs. By providing factory functions that introduce new inference sites, you can ensure correct type binding where standard generic inference previously failed.

Does currying for TypeScript inference require specific dependencies or components?

No, currying for TypeScript inference requires no external dependencies or components. It relies entirely on TypeScript's native generics system, using curried helpers and builder classes to manually establish the required inference sites.

When should I not use currying to resolve TypeScript inference issues?

You should not use currying to resolve TypeScript inference issues if your APIs cannot expose inference points via parameters or return curried functions. Without these explicit inference sites, the technique cannot ensure strong type safety.