javascript-typescript
JavaScript and TypeScript development with ES6+, Node.js, React, and modern web frameworks. Use for frontend, backend, or full-stack JavaScript/TypeScript projects.
When & Why to Use This Skill
This Claude skill is a comprehensive toolkit for modern JavaScript and TypeScript development, covering the entire stack from frontend React patterns to backend Node.js implementations. It provides developers with optimized TypeScript configurations, advanced type safety patterns, and ES6+ best practices to accelerate the delivery of scalable, high-quality web applications.
Use Cases
- Full-stack Web Development: Rapidly build and deploy end-to-end applications using React for dynamic user interfaces and Node.js for high-performance backend services.
- TypeScript Architecture & Type Safety: Implement robust type systems using discriminated unions, generic constraints, and utility types to minimize runtime errors and improve code maintainability.
- React Component & Hook Design: Create reusable UI components and custom hooks that follow modern functional programming patterns and efficient state management practices.
- Modernizing Legacy Codebases: Refactor older JavaScript projects to modern ES6+ standards, including optional chaining, nullish coalescing, and advanced array methods for cleaner code.
- Node.js Backend Optimization: Streamline server-side logic with standardized error handling, ES module integration, and asynchronous file system operations.
| name | javascript-typescript |
|---|---|
| description | JavaScript and TypeScript development with ES6+, Node.js, React, and modern web frameworks. Use for frontend, backend, or full-stack JavaScript/TypeScript projects. |
| source | wshobson/agents |
| license | MIT |
JavaScript/TypeScript Development
TypeScript Configuration
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"skipLibCheck": true,
"declaration": true,
"outDir": "./dist"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
Type Patterns
Utility Types
// Pick specific properties
type UserPreview = Pick<User, 'id' | 'name'>;
// Omit properties
type CreateUser = Omit<User, 'id' | 'createdAt'>;
// Make all properties optional
type PartialUser = Partial<User>;
// Make all properties required
type RequiredUser = Required<User>;
// Extract union types
type Status = 'pending' | 'active' | 'inactive';
type ActiveStatus = Extract<Status, 'active' | 'pending'>;
Discriminated Unions
type Result<T> =
| { success: true; data: T }
| { success: false; error: Error };
function handleResult<T>(result: Result<T>) {
if (result.success) {
console.log(result.data); // T
} else {
console.error(result.error); // Error
}
}
Generic Constraints
interface HasId {
id: string | number;
}
function findById<T extends HasId>(items: T[], id: T['id']): T | undefined {
return items.find(item => item.id === id);
}
Modern JavaScript
Destructuring & Spread
const { name, ...rest } = user;
const merged = { ...defaults, ...options };
const [first, ...others] = items;
Optional Chaining & Nullish Coalescing
const city = user?.address?.city ?? 'Unknown';
const count = data?.items?.length ?? 0;
Array Methods
const adults = users.filter(u => u.age >= 18);
const names = users.map(u => u.name);
const total = items.reduce((sum, item) => sum + item.price, 0);
const hasAdmin = users.some(u => u.role === 'admin');
const allActive = users.every(u => u.active);
React Patterns
// Props with children
interface CardProps {
title: string;
children: React.ReactNode;
}
// Event handlers
interface ButtonProps {
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
}
// Custom hooks
function useLocalStorage<T>(key: string, initial: T) {
const [value, setValue] = useState<T>(() => {
const stored = localStorage.getItem(key);
return stored ? JSON.parse(stored) : initial;
});
useEffect(() => {
localStorage.setItem(key, JSON.stringify(value));
}, [key, value]);
return [value, setValue] as const;
}
Node.js Patterns
// ES Modules
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
// Error handling
process.on('unhandledRejection', (reason) => {
console.error('Unhandled Rejection:', reason);
process.exit(1);
});