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 पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
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
Gather requirements - ask user:
- What test files have
asassertions causing problems? - Are they dealing with large objects where only some properties matter?
- Do they need to pass intentionally wrong data for error testing?
- What test files have
Install and migrate:
- Install:
npm i @total-typescript/shoehorn - Find test files with
asassertions:grep -r " as [A-Z]" --include="*.test.ts" --include="*.spec.ts" - Replace
as TypewithfromPartial() - Replace
as unknown as TypewithfromAny() - Add imports from
@total-typescript/shoehorn - Run type check to verify
- Install:
अक्सर पूछे जाने वाले सवाल
क्या मैं 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
कमेंट
- …
इस repository की और skills
ask-matt
310kयह आपके एजेंट को कोडिंग स्किल के एक सेट का मार्गदर्शक बनाती है, जो आपकी स्थिति के लिए सही स्किल की ओर इशारा करता है, विचार से लेकर भेजे गए कोड तक।
code-review
310kयह आपके बदलावों को आपकी रिपॉज़िटरी के कोडिंग मानकों और मूल स्पेक के साथ जांचती है, merge से पहले दोनों समीक्षाएं साथ-साथ चलाकर।
domain-modeling
310kयह एक साझा प्रोजेक्ट शब्दावली बनाती है और मुख्य डिज़ाइन फ़ैसले दर्ज करती है, ताकि आपका कोड वही शब्द इस्तेमाल करे जो आपकी टीम करती है।
implement-spec
310kएक पूरे स्पेक और उसके टिकट्स को काम करने वाले कोड में बदलती है, टिकट्स को क्रम से संभालते हुए और उन्हें एक branch में जोड़ते हुए।
मिलती-जुलती skills
test-driven-development
311kयह आपके एजेंट को किसी भी फ़ीचर या सुधार से पहले पहले असफल होने वाला टेस्ट लिखना, उसे असफल होते देखना, फिर पास करने वाला सबसे छोटा कोड लिखना सिखाती है।
verification-before-completion
311kयह आपके एजेंट को किसी काम, सुधार या build के पूरा या पास होने का दावा करने से पहले असली जांच चलाकर उसका आउटपुट पढ़ना सिखाती है।
cpp-testing
280kयह आपके एजेंट को C++ code के लिए tests लिखने और सुधारने देता है। यह testing tools सेट करने और errors ठीक करने में मदद करता है।