dalestudy/skills

typescript

TypeScript 타? 정의 및 베스트 프랙티스 스킬. 다음 상황에서 사용: (1) TypeScript 파일(.ts, .tsx) 작성 또는 수정 시, (2) 타? 정의(interface, type) 작? 시, (3) tsconfig.json 설정 또는 컴파일러 옵? 에러 해결 또는 타? 안전성 개선 시, (5) 제네릭, 유틸리티 타? 조작 작? 시, (6) 'typescript', 'ts', 'type', 'interface', 'generic' 키워드가 포함된 작? 시"

First seen Feb 1, 2026

Installation

$ npx skills add dalestudy/skills --skill typescript

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from dalestudy/skills.

npx skills add dalestudy/skills

Browse all from dalestudy/skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 4
License LICENSE
Default branch main
Open issues 3
Status Active

Skill metadata

Parsed from SKILL.md frontmatter.

Version1.0.0
LicenseMIT
CompatibilityRequires TypeScript compiler (tsc)
More metadata
author
DaleStudy
version
1.0.0

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 4,931 B
  • docs SUMMARY.md 484 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 372 installs

SKILL.md

TypeScript

TypeScript 핸드북 기반 타입 정의 및 베스트 프랙티스. 기본 문법·타입 조작·유틸리티 타입 상세는 [references/](references/) 및 Handbook 참고.

기본 원칙

1. 타입 추론 활용

불필요한 어노테이션 생략. 변경 시 이중 수정 부담 감소, 추론이 더 정확한 경우 많음.

// ❌
const name: string = "John";
const user: { name: string; age: number } = { name: "John", age: 30 };

// ✅
const name = "John";
const user = { name: "John", age: 30 };

2. 명시적 반환 타입

함수 계약 명확화, 반환 타입 오변경 방지. 공개 API·복잡한 로직에서 필수.

function calculateTotal(items: Item[]): number {
  return items.reduce((sum, item) => sum + item.price, 0);
}
async function fetchUser(id: string): Promise<User> {
  const res = await fetch(`/api/users/${id}`);
  return res.json();
}

3. any 사용 금지

타입 안전성·자동완성 무효화. unknown + 타입 가드 또는 구체 타입 사용.

// ❌
function process(data: any) {
  return data.value;
}

// ✅
function process(data: unknown): number {
  if (typeof data === "object" && data !== null && "value" in data)
    return (data as { value: number }).value;
  throw new Error("Invalid data");
}

함수 · 제네릭

  • 함수: 인자·반환 타입 명시. 오버로드 시 구현 시그니처는 유니온으로.
  • 제네릭: T, K extends keyof T 등 제약 명시. getProperty<T, K extends keyof T>(obj: T, key: K): T[K] 패턴 활용.

타입 가드

  • typeof, instanceof, in으로 분기 후 타입 좁히기
  • 복잡한 검사는 사용자 정의 가드 (value): value is T 사용

템플릿: assets/types.guards.ts

tsconfig

  • 프로젝트 성격에 맞는 tsconfig를 사용
  • 타입 안정성을 해치지 않는 선에서만 옵션을 조정
  • 앱/서버/라이브러리는 설정 파일을 분리
  • 타입 에러 회피 목적의 옵션 완화 금지

템플릿:

- assets/tsconfig.nextjs.ts
- assets/tsconfig.node.ts
- assets/tsconfig.react.ts

이벤트 타입

  • DOM / React 이벤트는 내장 타입 사용
  • 커스텀 이벤트만 별도 타입 정의
  • 이벤트 재정의 금지

템플릿: assets/types.events.ts

유틸리티 타입

  • TypeScript 내장 유틸리티 타입은 그대로 사용
  • 커스텀 유틸리티 타입만 정의

템플릿: assets/types.utils.ts

실전 패턴

  • interface 우선: 객체 계약·확장은 interface, 유니온/인터섹션은 type. API 설명은 명사형으로 작성 (/** 비활성화 상태 */).
  • as const: 리터럴·객체 불변 보존. typeof obj[keyof typeof obj] 로 이넘처럼 활용.
  • 브랜드 타입: type UserId = string & { readonly brand: unique symbol } 로 동일 원시 타입 구분.
  • 타입 단언 최소화: as 대신 타입 가드.
  • 제네릭 제약: T extends object 등 명시.

타입 에러 해결

에러 대응
Type 'X' is not assignable to type 'Y' 타입 가드로 분기 후 할당
Property 'X' does not exist on type 'Y' 타입 확장 또는 optional
Object is possibly 'null' or 'undefined' if (x == null) / ?. / ??
Argument of type 'X' is not assignable to parameter of type 'Y' 제네릭 T[] 또는 오버로드
Type 'X' cannot be used as an index type keyof typeof obj 사용

디버깅: 호버로 추론 확인, 가드·제네릭·유틸리티 타입으로 해결 후 as는 최후 수단.

참고

이 문서들은 규칙이 아니라 참고용, 판단 기준은 각 skill 문서를 우선