मुख्य सामग्री पर जाएँ
Skillpedia
टेस्टिंग310k · #121

migrate-to-shoehorn

यह क्या करती है

यह उन टेस्ट कोड को बदलती है जो type shortcuts इस्तेमाल करता है, और उन्हें shoehorn लाइब्रेरी के सुरक्षित helper functions में बदल देती है। यह उन डेवलपर्स के लिए है जो अधूरे टेस्ट डेटा के साथ TypeScript टेस्ट लिखते हैं।

कब इस्तेमाल करें

  • ✓जब आपकी टेस्ट फ़ाइलों में नकली डेटा के लिए as type assertions इस्तेमाल हों।
  • ✓जब आपको हर property लिखे बिना अधूरा टेस्ट डेटा चाहिए।
  • ✓जब आप अपने टेस्ट में as unknown as casts की जगह कुछ और इस्तेमाल करना चाहते हों।

Skill का लिंक

https://github.com/mattpocock/skills/blob/main/skills/misc/migrate-to-shoehorn/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/mattpocock/skills/blob/main/skills/misc/migrate-to-shoehorn/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“हमारी टेस्ट फ़ाइलों के as casts को shoehorn से बदल दीजिए, ताकि टेस्ट type-safe रहें।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

एजेंट लाइब्रेरी इंस्टॉल करता है और हर टेस्ट पैटर्न को उसके मेल खाते helper में लिख देता है, जैसे अधूरे डेटा के लिए fromPartial, या जान-बूझकर गलत डेटा के लिए fromAny। वह केवल टेस्ट कोड बदलता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Migrate to Shoehorn

Why shoehorn?

shoehorn lets you pass partial data in tests while keeping TypeScript happy. It replaces as assertions with type-safe alternatives.

Test code only. Never use shoehorn in production code.

Problems with as in tests:

  • Trained not to use it
  • Must manually specify target type
  • Double-as (as unknown as Type) for intentionally wrong data

Install

npm i @total-typescript/shoehorn

Migration patterns

Large objects with few needed properties

Before:

type Request = {
  body: { id: string };
  headers: Record<string, string>;
  cookies: Record<string, string>;
  // ...20 more properties
};

it("gets user by id", () => {
  // Only care about body.id but must fake entire Request
  getUser({
    body: { id: "123" },
    headers: {},
    cookies: {},
    // ...fake all 20 properties
  });
});

After:

import { fromPartial } from "@total-typescript/shoehorn";

it("gets user by id", () => {
  getUser(
    fromPartial({
      body: { id: "123" },
    }),
  );
});

as Type → fromPartial()

Before:

getUser({ body: { id: "123" } } as Request);

After:

import { fromPartial } from "@total-typescript/shoehorn";

getUser(fromPartial({ body: { id: "123" } }));

as unknown as Type → fromAny()

Before:

getUser({ body: { id: 123 } } as unknown as Request); // wrong type on purpose

After:

import { fromAny } from "@total-typescript/shoehorn";

getUser(fromAny({ body: { id: 123 } }));

When to use each

Function Use case
fromPartial() Pass partial data that still type-checks
fromAny() Pass intentionally wrong data (keeps autocomplete)
fromExact() Force full object (swap with fromPartial later)

Workflow

  1. Gather requirements - ask user:

    • What test files have as assertions causing problems?
    • Are they dealing with large objects where only some properties matter?
    • Do they need to pass intentionally wrong data for error testing?
  2. Install and migrate:

    • Install: npm i @total-typescript/shoehorn
    • Find test files with as assertions: grep -r " as [A-Z]" --include="*.test.ts" --include="*.spec.ts"
    • Replace as Type with fromPartial()
    • Replace as unknown as Type with fromAny()
    • Add imports from @total-typescript/shoehorn
    • Run type check to verify
अक्सर पूछे जाने वाले सवाल

क्या मैं shoehorn को प्रोडक्शन कोड में इस्तेमाल कर सकता हूं?

नहीं। स्किल कहती है कि यह केवल टेस्ट कोड के लिए है।

fromPartial क्या करता है?

यह आपको केवल वही fields देने देता है जो टेस्ट को चाहिए, और TypeScript फिर भी types जांचता है।

fromAny किसलिए है?

यह उन मामलों के लिए है जहां टेस्ट जान-बूझकर ऐसा डेटा देता है जो type से मेल नहीं खाता।

जानकारी

लेखक का मूल विवरण

Migrate test files from `as` type assertions to @total-typescript/shoehorn. Use when user mentions shoehorn, wants to replace `as` in tests, or needs partial test data.

repo: mattpocock/skills

लोकप्रियता

GitHub स्टार
310k
रैंकिंग में स्थान
#121
लाइसेंस
MIT
अपडेट की गई
1/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

ask-matt

310k

यह आपके एजेंट को कोडिंग स्किल के एक सेट का मार्गदर्शक बनाती है, जो आपकी स्थिति के लिए सही स्किल की ओर इशारा करता है, विचार से लेकर भेजे गए कोड तक।

AI और एजेंटएजेंट

code-review

310k

यह आपके बदलावों को आपकी रिपॉज़िटरी के कोडिंग मानकों और मूल स्पेक के साथ जांचती है, merge से पहले दोनों समीक्षाएं साथ-साथ चलाकर।

कोडिंगसामान्य कोडिंग

domain-modeling

310k

यह एक साझा प्रोजेक्ट शब्दावली बनाती है और मुख्य डिज़ाइन फ़ैसले दर्ज करती है, ताकि आपका कोड वही शब्द इस्तेमाल करे जो आपकी टीम करती है।

कोडिंगसामान्य कोडिंग

implement-spec

310k

एक पूरे स्पेक और उसके टिकट्स को काम करने वाले कोड में बदलती है, टिकट्स को क्रम से संभालते हुए और उन्हें एक branch में जोड़ते हुए।

कोडिंगसामान्य कोडिंग

मिलती-जुलती skills