본문으로 건너뛰기
cccskills
무료GitHub에 공개

typescript

Guide for implementing TypeScript in projects, including naming conventions, type definitions, and code style. Triggered when writing or refactoring TypeScript code.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md4.1 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

TypeScript Development Guide

This skill provides mandatory specifications for writing TypeScript in this project to ensure consistency, type safety, and code cleanliness.

1. Naming Conventions

1.1 Variables and Functions

  • Variables: Use snake_case (e.g., theme_value, is_dev).
  • Functions: Use camelCase (e.g., getAntdTheme, setGlobalAnimation).
  • Internal Props Objects: Use props_* prefix (e.g., props_side_bar).

1.2 Classes and Types

  • Classes: Use PascalCase (e.g., GlobalModel, Settings).
  • Interfaces/Types: Use PascalCase. Interfaces preferably start with I (e.g., IProps, IPropsSidebar).
  • Enum-like Types: Use literal union types instead of enum where possible (e.g., type Theme = 'light' | 'dark' | 'system').

2. Type Definitions

2.1 File Organization

  • Global Types: Place in packages/app/types/ or packages/app/typings/.
  • Local Types: Use types.ts file in the component or module directory.
  • Props: Define an IProps interface for each component, typically in the component file or adjacent types.ts.

2.2 Best Practices

  • Explicit Types: Prefer providing explicit type annotations for function parameters and complex return value types.
  • Utility Types: Leverage TypeScript's utility types (Pick, Omit, Partial, Exclude) to reuse existing definitions.
  • Strict Types: Avoid any. If the type is truly unknown, use unknown and perform type casting (cast) when necessary.
  • Type Alias vs. Interface: Use interface for object structures (especially props), use type for unions, intersections, or base types.

3. Code Style

3.1 Imports and Exports

  • Named Exports: Utility functions and models prefer named exports.
  • Default Exports: For the main component or main class in a file, use default export.
  • Pure Type Imports: Use import type for importing types to maintain clear process boundaries and reduce bundle size.
  • Path Aliases: Use @/ to reference the src directory (e.g., import { Settings } from '@/models').

3.2 Statements and Logic

  • Arrow Functions: Component definitions and small utility functions prefer arrow functions.
  • Destructuring: Use destructuring for props and objects to improve readability.
  • Conditional Logic: Use optional chaining (?.) and nullish coalescing (??) for safer property access.

3.3 Code Spacing and Blank Lines

Use blank lines to separate code with different execution styles or visual appearances. If two adjacent lines of code look stylistically different, a blank line must be added between them.

When to Add Blank Lines:

  • Between data fetching and return statements
  • Between variable calculation and usage
  • Between multiple consecutive operations (different independent steps)
  • Before early returns
  • Between different operation types (sync vs async, query vs mutation)
  • Before and after state changes

Recommended:

async getSnapshot(weight_threshold = 0.2) {
	const nodes = await this.query(sql.sql_get_snapshot_nodes(weight_threshold))
	const edges = await this.query(sql.sql_get_snapshot_edges(weight_threshold))

	return { nodes, edges }
}

async tick(threshold_override?: number) {
	const threshold = threshold_override ?? 0.5

	await this.exec(sql.sql_tick(threshold))
}

Avoid:

async getSnapshot(weight_threshold = 0.2) {
	const nodes = await this.query(sql.sql_get_snapshot_nodes(weight_threshold))
	const edges = await this.query(sql.sql_get_snapshot_edges(weight_threshold))
	return { nodes, edges }
}

4. Summary Checklist

  • Are variable names snake_case?
  • Are function names camelCase?
  • Are component props using IProps or IProps*?
  • Are pure type imports using import type?
  • Are local types placed in types.ts files?
  • Has any been avoided in favor of strict types or unknown?
  • Are blank lines used to separate different execution style code blocks?

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Maintain package-level `agentmap.md` files as outline-level maps of the real file tree and core responsibilities. Use when package structure or responsibility boundaries change and the corresponding `agentmap.md` must be created or updated.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MatrixAges/polywise6622026년 6월 11일 업데이트

Guides the generation, reading, and updating of agentmap.md files. This skill ensures a consistent and up-to-date codebase map for AI Agents.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MatrixAges/polywise6622026년 6월 11일 업데이트

Interacts with local browser via Chrome DevTools Protocol (only triggered after user explicitly requests to inspect, debug, or interact with pages open in Chrome)

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MatrixAges/polywise6622026년 6월 11일 업데이트

css

무료

Guides styling implementation using TailwindCSS + CSS Modules. Triggered when handling component styles, layout design, or CSS patterns.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MatrixAges/polywise6622026년 6월 11일 업데이트

Specialized for translating document files and their content into English. Triggered when localization, translation, or converting Chinese documents to English is requested.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MatrixAges/polywise6622026년 6월 11일 업데이트

Guides using eRPC (electron-tRPC) for inter-process communication (IPC) between Electron main and renderer processes. Triggered when handling Electron IPC or tRPC-based systems.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MatrixAges/polywise6622026년 6월 11일 업데이트

MatrixAges의 스킬 모두 보기

이 스킬의 문제 신고