Writing Typescript
Idiomatic TypeScript development. Use when writing TypeScript code, Node.js services, React apps, or discussing TS patterns. Emphasizes strict typing, composition, and modern tooling (bun/vite).
MCP get_skill({ skillId: "writing-typescript-b7954219" })Use this skill with your agent
Create a free account and connect via MCP
# TypeScript Development (2025)
## Core Principles
- **Strict typing**: Enable all strict checks
- **Parse, don't validate**: Transform untrusted data at boundaries
- **Composition over inheritance**: Small, focused functions
- **Explicit over implicit**: No `any`, prefer `unknown`
## Toolchain
```bash
bun # Runtime + package manager (fast)
vite # Frontend bundling
vitest # Testing
eslint # Linting
prettier # Formatting
```
## Quick Patterns
### Type Guards
```typescript
function isUser(value: unknown): value is User {
return typeof value === "object" && value !== null && "id" in value;
}
```
### Discriminated Unions
```typescript
type Result<T, E = Error> = { ok: true; value: T } | { ok: false; error: E };
function processResult<T>(result: Result<T>): T {
if (result.ok) return result.value;
throw result.error;
}
```
### Utility Types
```typescript
type UserUpdate = Partial<User>;
type UserSummary = Pick<User, "id" | "name">;
type UserWithoutPassword = Omit<User, "password">;
type ReadonlyUser = Readonly<User>;
```
## tsconfig.json Essentials
```json
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true,
"noImplicitReturns": true,
"isolatedModules": true
}
}
```
## References
- [PATTERNS.md](PATTERNS.md) - Code patterns and style
- [REACT.md](REACT.md) - React component patterns
- [TESTING.md](TESTING.md) - Testing with vitest
## Commands
```bash
bun install # Install deps
bun run build # Build
bun test # Test
bun run lint # Lint
bun run format # Format
```
---
## Gotchas
- **`import type` with `verbatimModuleSyntax` and named exports**: type-only import of a value triggers errors. Fix: `import { type Foo } from "mod"` (inline marker).
- **`as const` on object: readonly AND literal-narrowed** — different from `as Foo` (asserts type) or `satisfies Foo` (validates without widening).
- **`satisfies` validates without widening; `as` widens** — using `as` where you wanted `satisfies` loses literal types silently.
- **`Array<T>.includes(x)` requires `x` to be of type `T`** — narrowing-from-union doesn't work; the standard fix is a type-predicate helper.
- **`strictNullChecks: false` makes `T` mean `T | null | undefined` for ALL types** — partial migrations leave types that lie about nullability.
- **`tsconfig.json` `extends` doesn't recursively merge `compilerOptions.paths`** — child paths REPLACE parent paths, not merge.Related Skills
More skills in Software Engineering
Accessibility Standards
Comprehensive web accessibility standards based on WCAG 2.2 AA, with 38+ anti-patterns, legal enforcement context (EAA, ADA Title II), WAI-ARIA patterns, and framework-specific fixes for modern web frameworks and libraries.
Accord
Authoring unified specification packages across Business/Development/Design teams via staged elaboration (L0 Vision → L1 Requirements → L2 Team Detail → L3 Acceptance Criteria). No code. Use when authoring cross-team specs, building L0-L3 packages, or aligning Biz/Dev/Design on a single source of truth.
Acquire Codebase Knowledge
Use this skill when the user explicitly asks to map, document, or onboard into an existing codebase. Trigger for prompts like "map this codebase", "document this architecture", "onboard me to this repo", or "create codebase docs". Do not trigger for routine feature implementation, bug fixes, or narrow code edits unless the user asks for repository-level discovery.
Acreadiness Assess
Run the AgentRC readiness assessment on the current repository and produce a static HTML dashboard at reports/index.html. Wraps `npx github:microsoft/agentrc readiness` and hands off rendering to the @ai-readiness-reporter custom agent. Supports policies (--policy) for org-specific scoring. Use when asked to assess, audit, or score the AI readiness of a repo.
Acreadiness Generate Instructions
Generate tailored AI agent instruction files via AgentRC instructions command. Produces .github/copilot-instructions.md (default, recommended for Copilot in VS Code) plus optional per-area .instructions.md files with applyTo globs for monorepos. Use after running /acreadiness-assess to close gaps in the AI Tooling pillar.
Acreadiness Policy
Help the user pick, write, or apply an AgentRC policy. Policies customise readiness scoring by disabling irrelevant checks, overriding impact/level, setting pass-rate thresholds, or chaining org baselines with team overrides. Use when the user asks about strict mode, AI-only scoring, custom weights, CI gating, or wants org-wide standardisation.
Explore Other Categories
Skills from other categories with shared topics
Python Project Skill
Python Project Skill linked from Juliano Barbosa Claude Code Skills, with the upstream skill instructions available on GitHub.
Robusta Dev Skill
Robusta Dev Skill linked from Juliano Barbosa Claude Code Skills, with the upstream skill instructions available on GitHub.
1password Skill
1password Skill linked from Juliano Barbosa Claude Code Skills, with the upstream skill instructions available on GitHub.