Skip to content
moai-lang-typescript logo

Modern TypeScript Development — Enterprise v4.0

moai-lang-typescript

Enterprise TypeScript with strict typing and modern ecosystem TypeScript 5.9.3, Next.js 16, Turbopack, React 19, tRPC, Zod for type-safe schemas; activates for full-stack development, API contract definition, type safety enforcement, and framework-agnostic TypeScript patterns.

mattnigh/skills_collection0installs24stars

SKILL.md

Full skill instructions

Modern TypeScript Development — Enterprise v4.0

Quick Summary

Primary Focus: TypeScript 5.9 with strict typing, Next.js 16, React 19, and type-safe APIs Best For: Full-stack development, API contracts, type safety, component libraries Key Libraries: React 19, Next.js 16, tRPC 11, Zod 3.23, Vitest 2.x Auto-triggers: TypeScript, Next.js, React, tRPC, strict types, type safety, API routes

VersionReleaseSupport
TypeScript 5.9.3Aug 2025Active
React 19.xDec 2024Active
Next.js 16.x2025Active
Node.js 22 LTSOct 2024Apr 2027

Three-Level Learning Path

Level 1: Fundamentals (Read examples.md)

Core TypeScript concepts and patterns:

  • Type System: Primitives, unions, intersections, generics, utility types
  • React 19: Server components, transitions, ref as prop, new hooks
  • Next.js 16: File-based routing, API routes, server actions, Turbopack
  • tRPC Basics: Type-safe API definition and client usage
  • Examples: See examples.md for full code samples

Level 2: Advanced Patterns (See reference.md)

Production-ready enterprise patterns:

  • Advanced Types: Conditional types, mapped types, generic constraints
  • Zod Validation: Runtime schema validation with type inference
  • Component Testing: Vitest with React Testing Library
  • API Design: tRPC routers, middleware, context
  • Pattern Reference: See reference.md for API details and best practices

Level 3: Production Deployment (Consult security/​performance skills)

Enterprise deployment and optimization:

  • Build Optimization: Turbopack configuration, code splitting
  • Docker Deployment: Multi-stage builds, environment setup
  • Performance: Web Vitals, caching strategies, bundle analysis
  • Monitoring: Error tracking, metrics, observability
  • Details: Skill("moai-essentials-perf"), Skill("moai-security-backend")

Technology Stack (November 2025 Stable)

Language & Runtime

  • TypeScript 5.9.3 (August 2025, deferred module evaluation)
  • Node.js 22.11.0 LTS (April 2027 support)
  • JavaScript ES2020 target for compatibility

Frontend Framework

  • React 19.x (Server Components, Actions, new Hooks API)
  • Next.js 16.x (Turbopack, App Router, Server Components)
  • Turbopack (Rust-based bundler, 2x faster builds)

Type-Safe Ecosystem

  • tRPC 11.x (End-to-end type safety without code generation)
  • Zod 3.23.x (Runtime validation with TypeScript inference)
  • Vitest 2.x (Unit testing with Jest compatibility)

Package Management

  • npm 11.x, pnpm 9.x, yarn 4.x (all supported)
  • Node Modules: ESM modules with bundler resolution

TypeScript Type System

Basic Types

// Primitives
const name: string = "John";
const age: number = 30;
const active: boolean = true;

// Union types for flexible APIs
type Status = "pending" | "approved" | "rejected";
type Result = string | number;

// Intersection types for combining
type Admin = User & { role: "admin"; permissions: string[] };

Generics & Constraints

// Generic function
function getFirstElement<T>(arr: T[]): T {
  return arr[0];
}

// Generic with constraints
function merge<T extends object, U extends object>(obj1: T, obj2: U): T & U {
  return { ...obj1, ...obj2 };
}

Utility Types

// Common patterns
type Readonly<T> = { readonly [K in keyof T]: T[K] };
type Partial<T> = { [K in keyof T]?: T[K] };
type Pick<T, K> = { [P in K]: T[P] };
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
type Record<K, T> = { [P in K]: T };

React 19 Components

Server & Client Components

// Server Component
'use server'
export async function UserProfile({ userId }: { userId: string }) {
  const userData = await fetchUser(userId);
  return <div>{userData.name}</​div>;
}

// Client Component with State
'use client'
export function Counter() {
  const [count, setCount] = useState(0);
  return <button onClick={() => setCount(count + 1)}>{count}</​button>;
}

React Hooks

// useState, useEffect, useContext
const [state, setState] = useState<number>(0);
useEffect(() => { /​* ... */ }, []);

// useTransition for non-blocking updates
const [isPending, startTransition] = useTransition();

// useRef for DOM access
const inputRef = useRef<HTMLInputElement>(null);

Next.js 16 Full-Stack Development

File-Based Routing & Layouts

app/
├── page.tsx                  # Root page
├── layout.tsx                # Root layout
├── api/​users/​route.ts        # API route: /​api/​users
└── dashboard/
    ├── page.tsx              # /​dashboard
    └── [id]/​page.tsx         # /​dashboard/[id]

API Routes

export async function GET(request: NextRequest) {
  return NextResponse.json({ users: [] });
}

export async function POST(request: NextRequest) {
  const data = await request.json();
  return NextResponse.json(data, { status: 201 });
}

Server Actions

'use server'

export async function createUser(formData: FormData) {
  const name = formData.get('name');
  await db.users.create({ data: { name } });
  revalidatePath('/​users');
}

Type-Safe APIs with tRPC

Router Definition

export const router = t.router({
  user: t.router({
    list: t.procedure.query(() => db.user.findMany()),

    getById: t.procedure
      .input(z.object({ id: z.string() }))
      .query(async ({ input }) =>
        db.user.findUnique({ where: { id: input.id } })
      )
  })
});

export type AppRouter = typeof router;

Client Usage (Fully Typed)

const { data: users } = trpc.user.list.useQuery();
// All types inferred from server router!

Runtime Validation with Zod

Schema Definition

const UserSchema = z.object({
  id: z.string().uuid(),
  name: z.string().min(1).max(100),
  email: z.string().email()
});

type User = z.infer<typeof UserSchema>;

// Validation
const user = UserSchema.parse(data);  // Throws on error
const result = UserSchema.safeParse(data);  // Returns { success, data, error }

Testing

Unit Tests with Vitest

import { describe, it, expect, vi } from 'vitest';

describe('Math', () => {
  it('adds numbers', () => {
    expect(add(2, 3)).toBe(5);
  });

  it('calls callback', () => {
    const fn = vi.fn();
    execute(fn);
    expect(fn).toHaveBeenCalled();
  });
});

Component Tests

import { render, screen } from '@testing-library/​react';

it('renders button', () => {
  render(<Button>Click me</​Button>);
  expect(screen.getByRole('button')).toBeInTheDocument();
});

Production Best Practices

  1. Enable strict mode in tsconfig.json for maximum type safety
  2. Use Zod for runtime validation combined with TypeScript types
  3. Prefer tRPC over REST for end-to-end type safety
  4. Use Server Components by default in Next.js 16
  5. Implement proper error handling with discriminated unions
  6. Test with Vitest for fast, type-safe unit tests
  7. Leverage TypeScript utility types for DRY code
  8. Use conditional types for advanced type manipulations
  9. Monitor Web Vitals in production environments
  10. Build with Turbopack for faster development cycles

Learn More


Skills: Skill("moai-essentials-debug"), Skill("moai-essentials-perf"), Skill("moai-security-backend") Auto-loads: TypeScript projects mentioning Next.js, React, tRPC, strict types, type safety

More skills from mattnigh

spring-framework-patterns logo
mattnigh/skills_collection

spring-framework-patterns

Comprehensive Spring Framework and Spring Boot best practices including dependency injection patterns, bean lifecycle and scopes, REST API development, Spring Data JPA, service layer design, Spring Security, testing strategies, caching, AOP, async processing, error handling, and common anti-patte...

24 0
View

TypeScript厳格モードによる型安全性設計を専門とするスキル。 📖 参照書籍: - 『Effective TypeScript』(Dan Vanderkam): 型設計 📚 リソース参照: - `resources/Level1_basics.md`: レベル1の基礎ガイド - `resources/Level2_intermediate.md`: レベル2の実務ガイド - `resources/Level3_advanced.md`: レベル3の応用ガイド - `resources/Level4_expert.md`: レベル4の専門ガイド - `resources/di...

24 0
View
deploying-cloud-k8s logo
mattnigh/skills_collection

deploying-cloud-k8s

Deploys applications to cloud Kubernetes (AKS/GKE/DOKS) with CI/CD pipelines. Use when deploying to production, setting up GitHub Actions, troubleshooting deployments. Covers build-time vs runtime vars, architecture matching, and battle-tested debugging.

24 0
View
moai-alfred-agent-guide logo
mattnigh/skills_collection

moai-alfred-agent-guide

19-agent team structure, decision trees for agent selection, Haiku vs Sonnet model selection, and agent collaboration principles. Use when deciding which sub-agent to invoke, understanding team responsibilities, or learning multi-agent orchestration.

24 0
View
mermaid-diagram-generator logo
mattnigh/skills_collection

mermaid-diagram-generator

Converts architecture descriptions, module specs, or workflow docs into Mermaid diagrams. Use when visualizing brick module relationships, workflows (DDD, investigation), or system architecture. Supports: flowcharts, sequence diagrams, class diagrams, state machines, entity relationship diagrams,...

24 0
View
pre-flight-check logo
mattnigh/skills_collection

pre-flight-check

INVOKE FIRST before any code work. Validates git workflow (branch, issue, worklog) and checks approach. Use at START of every task and END before completing. Prevents skipped steps.

24 0
View
browser-dev-tools logo
mattnigh/skills_collection

browser-dev-tools

This skill should be used when working with browser-rendered artifacts (i.e. Bun, React/React Native) to proactively validate that development work on localhost is being built appropriately and to support debugging browser-rendered content. Use this skill after making frontend changes to verify t...

24 0
View
lead-dev logo
mattnigh/skills_collection

lead-dev

Lead Développeur - Coordination technique opérationnelle, code review, mentoring et livraison. Pair de web-dev-process au niveau OPÉRATIONS.

24 0
View
worker-monitor logo
mattnigh/skills_collection

worker-monitor

Monitor Docker workers, RQ queue health, and auto-scale workers (max 4). Use when: checking job progress, monitoring queue depth, scaling workers up/down, diagnosing slow processing, or waiting for jobs to complete. Referenced by data-quality skill during reprocessing.

24 0
View
quality-advisor logo
mattnigh/skills_collection

quality-advisor

Proactive quality guidance system that monitors artifact creation and provides real-time feedback on documentation quality

24 0
View
bump-version logo
mattnigh/skills_collection

bump-version

This skill should be used when the user wants to bump the version number in the workspace. It updates versions across all pyproject.toml files (root, tde, and tda packages) and the CHANGELOG.md to keep them synchronized.

24 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View