본문으로 건너뛰기
Skillpedia
일반 코딩48k · #5901

typescript

하는 일

이 가이드는 더 효율적이고 명확한 TypeScript/JavaScript 코드를 작성하는 방법을 가르칩니다. 코드를 더 복잡하거나 느리게 만드는 흔한 방식을 피하고, 더 단순하고 빠른 대안을 제안하는 예시를 보여 줍니다.

사용하는 경우

  • ✓TypeScript나 JavaScript 코드를 작성할 때.
  • ✓코드를 더 읽기 쉽게 만들고 싶을 때.
  • ✓코드의 성능을 최적화하는 경우.

스킬 링크

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에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/super-code/typescript/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“JavaScript에서 이 반복문을 더 효율적으로 다시 작성해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

이 가이드는 코드 예시로 '예전 방식'(덜 효율적)과 '새로운 방식'(더 효율적)을 비교합니다. 배열과 객체 작업, 함수, TypeScript의 타입 사용을 다룹니다.

기술 내용 (원본 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

  1. Array & Object Operations
  2. Destructuring & Spread
  3. Async / Promises
  4. Functions & Closures
  5. TypeScript Types
  6. React (if applicable)
  7. 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

…
자주 묻는 질문

'디스트럭처링과 스프레드'란 무엇인가요?

배열이나 객체에서 값을 꺼내 별도 변수에 넣는 것(디스트럭처링)이나, 배열의 요소나 객체의 속성을 다른 곳에 펼쳐 넣는 것(스프레드)입니다. 코드를 더 간결하게 만듭니다.

`.then()` 대신 `async/await`를 쓰는 이유는 무엇인가요?

`async/await`는 비동기 코드(시간이 걸리는 작업을 다루는 코드)를 한 줄씩 실행되는 동기 코드처럼 보이게 합니다. 그래서 읽고 오류를 관리하기가 더 쉽습니다.

'타입 단언'이란 무엇인가요?

TypeScript가 증명하지 못해도 어떤 값이 특정 타입이라고 알려 주는 것입니다. 일반적으로 피하고, TypeScript가 타입을 추론하게 하거나 타입 검사를 사용하는 것이 좋습니다.

상세 정보

작성자의 원본 설명

Language-specific super-code guidelines for typescript.

repo: sickn33/agentic-awesome-skills

인기도

GitHub 스타
48k
순위
#5901
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬