home / skills / pluginagentmarketplace / custom-plugin-typescript / fundamentals

fundamentals skill

/skills/fundamentals

This skill helps you master TypeScript fundamentals, enabling safe typing with basic types, interfaces, and type annotations for robust code.

npx playbooks add skill pluginagentmarketplace/custom-plugin-typescript --skill fundamentals

Review the files below or copy the command above to add this skill to your agents.

Files (6)
SKILL.md
1.1 KB
---
name: fundamentals
description: TypeScript type system fundamentals and basic typing patterns
sasmp_version: "1.3.0"
bonded_agent: 01-typescript-fundamentals
bond_type: PRIMARY_BOND
---

# TypeScript Fundamentals Skill

## Overview
Master TypeScript's type system fundamentals including basic types, interfaces, and type annotations.

## Topics Covered

### Basic Types
- Primitive types (string, number, boolean)
- Arrays and tuples
- Enums
- Any, unknown, never, void
- Null and undefined handling

### Type Annotations
- Variable annotations
- Function parameters and returns
- Object type annotations
- Type inference
- Type assertions

### Interfaces
- Interface declaration
- Optional properties
- Readonly properties
- Index signatures
- Interface extension

### Type Aliases
- Type alias syntax
- Union types
- Intersection types
- Literal types
- Type narrowing

### Functions
- Function type expressions
- Call signatures
- Overloads
- Generic functions
- Rest parameters

## Prerequisites
- JavaScript fundamentals
- ES6+ features

## Learning Outcomes
- Write type-safe code
- Use interfaces effectively
- Apply type narrowing
- Understand type inference

Overview

This skill teaches TypeScript type system fundamentals and common typing patterns to help you write safer, more predictable code. It covers primitive and composite types, interfaces, type aliases, function typing, and essential concepts like type inference and narrowing. By the end, you will be able to add clear, maintainable types to JavaScript projects.

How this skill works

The skill presents concise explanations and examples for each core topic: basic types, annotations, interfaces, aliases, and function types. It highlights practical patterns such as optional and readonly properties, union/intersection types, generics, and overloads, and shows how type inference and assertions interact with explicit annotations. Each concept is framed around typical coding scenarios so you can apply types incrementally to an existing codebase.

When to use it

  • Adding type safety to a JavaScript codebase or new TypeScript project
  • Defining clear APIs with interfaces and type aliases
  • Writing reusable, generic functions and libraries
  • Refactoring loosely typed code to reduce runtime errors
  • Learning to use union types and narrowing for safer control flow

Best practices

  • Prefer specific types over any; use unknown when input must be validated first
  • Rely on type inference for local variables and annotate public API surfaces
  • Use interfaces for object shapes and type aliases for unions/intersections
  • Favor readonly and optional modifiers to express intent and immutability
  • Introduce generics for reusable components and keep signatures narrow
  • Use discriminated unions for safe runtime branching and clear narrowing

Example use cases

  • Annotating function parameters and return values to document and enforce behavior
  • Modeling API responses with interfaces and optional properties
  • Creating utility types with aliases, unions, and intersections
  • Building generic data structures like typed containers or mappers
  • Refactoring callbacks and event handlers with precise function types

FAQ

When should I use an interface vs a type alias?

Use interfaces to describe object shapes and support declaration merging; use type aliases for unions, intersections, primitives, and more complex type expressions.

Is it okay to use any during migration?

Temporary use of any can speed migration, but prefer unknown or gradual typing techniques to avoid losing type safety permanently.