typescript
यह क्या करती है
यह गाइड बताती है कि TypeScript/JavaScript code को ज़्यादा कुशल और साफ़ कैसे लिखें। इसमें ऐसी आम आदतों के उदाहरण हैं जो code को उलझा या धीमा बना सकती हैं, और उनके सरल व तेज़ विकल्प सुझाए गए हैं।
कब इस्तेमाल करें
- ✓TypeScript या JavaScript code लिखते समय।
- ✓जब आप अपने code को ज़्यादा पढ़ने लायक बनाना चाहते हों।
- ✓अपने code की performance बेहतर करने के लिए।
Skill का लिंक
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/super-code/typescript/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मैं JavaScript में इस loop को और कुशल कैसे बनाऊँ?”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
गाइड code उदाहरणों के ज़रिए 'पुराने तरीके' (कम कुशल) की तुलना 'नए तरीके' (ज़्यादा कुशल) से करती है। इसमें array और object operations, functions और TypeScript में types के इस्तेमाल को शामिल किया गया है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
TypeScript / JavaScript: Idiomatic Efficiency Reference
When to Use
- Use this skill when the task matches this description: Language-specific super-code guidelines for typescript.
Table of Contents
- Array & Object Operations
- Destructuring & Spread
- Async / Promises
- Functions & Closures
- TypeScript Types
- React (if applicable)
- Anti-patterns specific to TS/JS
1. Array & Object Operations {#arrays}
// ❌ Imperative push loop
const result: string[] = []
for (const item of items) {
if (item.active) result.push(item.name.toUpperCase())
}
// ✅
const result = items.filter(i => i.active).map(i => i.name.toUpperCase())
// ❌ Manual reduce for sum
let total = 0
for (const o of orders) total += o.amount
// ✅
const total = orders.reduce((sum, o) => sum + o.amount, 0)
// ❌ Manual object copy + override
const updated = Object.assign({}, user)
updated.name = "Alice"
// ✅
const updated = { ...user, name: "Alice" }
// ❌ Existence check before property access
const city = user.address ? user.address.city : undefined
// ✅
const city = user.address?.city
2. Destructuring & Spread {#destructuring}
// ❌ Separate variable assignments
const name = user.name
const age = user.age
// ✅
const { name, age } = user
// ❌ Index access for array elements
const first = arr[0]
const second = arr[1]
// ✅
const [first, second] = arr
// ❌ Merging arrays with concat
const merged = a.concat(b).concat(c)
// ✅
const merged = [...a, ...b, ...c]
// ❌ Omitting a key by delete (mutates)
const copy = { ...obj }
delete copy.password
// ✅ — destructure to omit
const { password, ...safe } = obj
3. Async / Promises {#async}
// ❌ Promise chain when async/await is cleaner
fetchUser(id)
.then(user => fetchOrders(user.id))
.then(orders => process(orders))
.catch(handleError)
// ✅
try {
const user = await fetchUser(id)
const orders = await fetchOrders(user.id)
process(orders)
} catch (e) {
handleError(e)
}
// ❌ Sequential awaits for independent operations
const user = await fetchUser(id)
const config = await fetchConfig()
// ✅ — run in parallel
const [user, config] = await Promise.all([fetchUser(id), fetchConfig()])
// ❌ Wrapping already-async function in new Promise
const result = await new Promise((resolve) => {
someAsyncFn().then(resolve)
})
// ✅
const result = await someAsyncFn()
Don't await inside a .map() without Promise.all — it sequences what should be parallel.
4. Functions & Closures {#functions}
// ❌ Arrow function with unnecessary block body
const double = (x: number) => { return x * 2 }
// ✅
const double = (x: number) => x * 2
// ❌ Default parameter with if-guard
function greet(name?: string) {
if (!name) name = "World"
return `Hello, ${name}`
}
// ✅
function greet(name = "World") {
return `Hello, ${name}`
}
// ❌ IIFE for no reason in module scope
;(function() {
const x = compute()
doSomething(x)
})()
// ✅ — just top-level statements in a module
const x = compute()
doSomething(x)
5. TypeScript Types {#types}
// ❌ Explicit return type when inference is obvious
function add(a: number, b: number): number {
return a + b
}
// ✅ — let TS infer simple return types
function add(a: number, b: number) {
return a + b
}
// ❌ any
function process(data: any) { ... }
// ✅ — use unknown + type guard, or a proper type/generic
function process<T extends Record<string, unknown>>(data: T) { ... }
// ❌ Redundant interface for single-use inline shape
interface UserNameProps { name: string }
function UserName({ name }: UserNameProps) { ... }
// ✅ — inline for single-use
function UserName({ name }: { name: string }) { ... }
// Extract interface when reused in 2+ places
// ❌ Type assertion (as) to silence a real type error
const el = document.getElementById("app") as HTMLDivElement
el.innerText = "hi" // crashes if el is null
// ✅
const el = document.getElementById("app")
if (!(el instanceof HTMLDivElement)) throw new Error("Missing #app")
el.innerText = "hi"
Prefer type for unions/intersections/aliases; interface for extensible object shapes.
6. React (if applicable) {#react}
// ❌ Effect for derived state
…
अक्सर पूछे जाने वाले सवाल
'Destructuring & Spread' क्या है?
यह array या object से values को अलग-अलग variables में निकालने (destructuring) या array के elements और object की properties को किसी दूसरी जगह फैलाने (spread) का तरीका है, जिससे code छोटा और साफ़ होता है।
`async/await` को `.then()` की जगह क्यों इस्तेमाल करें?
`async/await` asynchronous code (यानी ऐसे काम जिनमें समय लगता है) को synchronous code (जो एक-एक line करके चलता है) जैसा दिखाता है, जिससे उसे पढ़ना और errors संभालना आसान हो जाता है।
'Type Assertion' क्या है?
यह TypeScript को बताना है कि आपको पक्का पता है कि कोई value किसी खास type की है, भले ही TypeScript उसे साबित न कर सके। आम तौर पर इससे बचना बेहतर है और TypeScript को खुद types पहचानने दें या type checks इस्तेमाल करें।
जानकारी
लेखक का मूल विवरण
Language-specific super-code guidelines for typescript.
लोकप्रियता
- GitHub स्टार
- 48k
- रैंकिंग में स्थान
- #5901
- लाइसेंस
- MIT
- अपडेट की गई
- 15/10/2026
कमेंट
- …
इस repository की और skills
00-andruia-consultant
48kआपके एजेंट को AI प्रोजेक्ट शुरू करने या उन्हें बेहतर बनाने में मदद करता है। यह code का विश्लेषण करता है, tools सुझाता है और स्पेनिश भाषा में action plan बनाता है।
007
48kआपका एजेंट security audit और threat modeling करता है। यह प्रोजेक्ट को हमलों और कमजोरियों से बचाने में काम आता है।
10-andruia-skill-smith
48kआपके एजेंट को AI tools बनाने या उन्हें बेहतर करने में मदद करता है। यह तय करता है कि tools कैसे काम करेंगे, documentation लिखता है और structure की जांच करता है।
20-andruia-niche-intelligence
48kआपका एजेंट किसी खास industry का summary बनाता है। भरोसेमंद स्रोतों की मदद से यह प्रोजेक्ट का संदर्भ, नियम, इस्तेमाल के तरीके और जोखिम समझने में मदद करता है।
मिलती-जुलती skills
diffs
394kयह आपके एजेंट को बदलावों का असली diff बनाने देती है, जिसे व्यूअर लिंक या इमेज फ़ाइल के रूप में साझा किया जा सकता है, हाथ से लिखे सारांश के बजाय।
coding-agent
394kयह आपके एजेंट को बड़े कोडिंग काम Codex, Claude Code या OpenCode को बैकग्राउंड वर्कर के रूप में सौंपने, फिर उसकी प्रगति जांचने में मदद करती है।
gh-issues
394kयह आपके एजेंट को GitHub issues खोजने, उनमें से काम करने लायक चुनने, और सुधार के साथ pull requests खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।