Review TypeScript code for type safety, best practices, and modern patterns.
Reviews TypeScript code for type safety, strict mode compliance, and modern patterns. Identifies `any` types, null safety issues, and missing exhaustive checks in your codebase.
/plugin marketplace add KreativReason/merged-end-to-end-ai-dpp---e2e-cli/plugin install kreativreason-e2e-pipeline@kreativreason-marketplaceReview TypeScript code for type safety, best practices, and modern patterns.
// Good: Proper typing
interface User {
id: string;
email: string;
role: 'admin' | 'user';
createdAt: Date;
}
function getUser(id: string): Promise<User | null> {
return db.users.findUnique({ where: { id } });
}
// Bad: Any types, loose typing
function getUser(id: any): any {
return db.users.findUnique({ where: { id } });
}
// tsconfig.json should have:
{
"compilerOptions": {
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitReturns": true
}
}
// Good: Discriminated unions
type Result<T> =
| { success: true; data: T }
| { success: false; error: Error };
// Good: Const assertions
const ROLES = ['admin', 'user', 'guest'] as const;
type Role = typeof ROLES[number];
// Good: Utility types
type UserUpdate = Partial<Pick<User, 'email' | 'name'>>;
| Check | Description |
|---|---|
No any types | Explicit types required |
| Null safety | Proper null/undefined handling |
| Exhaustive checks | Switch statements handle all cases |
| Generics usage | Proper generic constraints |
| Import types | Use import type for type-only imports |
| Readonly usage | Immutability where appropriate |
{
"artifact_type": "typescript_review",
"status": "pass|warn|fail",
"data": {
"target": "PR #123",
"typescript_version": "5.3",
"strict_mode": true,
"findings": [
{
"id": "TS-001",
"severity": "high",
"title": "Implicit Any Type",
"file": "src/utils/parser.ts",
"line": 23,
"code": "function parse(data) {",
"suggestion": "function parse(data: unknown): ParsedData {"
},
{
"id": "TS-002",
"severity": "medium",
"title": "Missing Null Check",
"file": "src/services/user.ts",
"line": 45,
"description": "Possible null dereference",
"suggestion": "Add optional chaining or null check"
}
],
"type_coverage": {
"percentage": 94.5,
"untyped_files": ["src/legacy/old-module.ts"]
}
}
}
unknown over anyas const for literal typesimport typeany without explicit justification@ts-ignore!) carelesslyYou are an elite AI agent architect specializing in crafting high-performance agent configurations. Your expertise lies in translating user requirements into precisely-tuned agent specifications that maximize effectiveness and reliability.