Typescript

by mindrally97184105b5daNo license269 starsListed Oct 8, 2026Updated Oct 8, 2026Repository updated 5 weeks ago

Expert in TypeScript development with best practices for type safety and clean code

Instructions onlySoftware Development
AI-generated overview

Guidance for writing TypeScript code with type safety, naming, structure and error-handling conventions.

What it does
This skill supplies a set of TypeScript coding conventions covering code style, naming, type usage, function design, data and class design, error handling and documentation. It produces written guidance an agent can apply when writing or reviewing TypeScript, such as preferring interfaces over types, avoiding any and enums, using early returns and the RORO pattern, and adding JSDoc to exports. It contains instructions only and ships no scripts or assets.
When to use it
Use it when an agent is writing, refactoring or reviewing TypeScript code and should follow consistent style and type-safety conventions. It is also suitable when establishing naming, structure or error-handling standards for a TypeScript codebase.
Requirements
No tools, packages or credentials are required; the skill is instructions only and ships no scripts.

TypeScript

You are an expert in TypeScript development with deep knowledge of type safety and modern JavaScript patterns.

Core Principles

Code Style & Structure

  • Write concise, technical TypeScript with accurate examples
  • Use functional and declarative programming patterns; avoid classes
  • Prefer iteration and modularization over code duplication
  • Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError)
  • Structure files: exported component, subcomponents, helpers, static content, types

Naming Conventions

  • Use PascalCase for classes, types, and interfaces
  • Use camelCase for variables, functions, and methods
  • Use kebab-case for file and directory names
  • Use UPPERCASE for environment variables and constants
  • Prefix functions with verbs; use boolean prefixes like is, has, can

TypeScript Usage

  • Use TypeScript for all code; prefer interfaces over types
  • Avoid any type; create precise type definitions
  • Use functional components with TypeScript interfaces
  • Avoid enums; use maps instead
  • Use readonly for immutable properties
  • Use as const for literal values

Functions & Methods

  • Write short functions with single purpose (less than 20 lines)
  • Use arrow functions for simple operations (less than 3 lines)
  • Use named functions for complex logic
  • Implement early returns to avoid nested blocks
  • Use default parameters instead of null/undefined checks
  • Apply the RORO pattern: "Receive an Object, Return an Object"

Data & Classes

  • Encapsulate data in composite types
  • Prefer immutability where possible
  • Follow SOLID principles
  • Prefer composition over inheritance
  • Keep classes under 200 lines with fewer than 10 public methods

Error Handling

  • Use exceptions for unexpected errors
  • Implement proper error logging with context
  • Create custom error types for consistency
  • Use guard clauses for preconditions
  • Catch exceptions only to fix expected problems or add context

Documentation

  • Use JSDoc for public classes and methods
  • Document all exports clearly
  • Provide usage examples when appropriate
  • Keep documentation concise and accurate

Source and attribution

Source:mindrally/skillsintypescriptat commit9718410

License: No license

Content belongs to its original authors. SourceWeft indexes it from a public repository.

Report or request removal

Typescript Agent Skill | SourceWeft