Analyzes, refactors, and implements TypeScript code with proper types, converts JavaScript to TypeScript, implements decorators, fixes type errors, and enforces type safety in Angular projects.
Convert JavaScript to TypeScript, fix type errors, and implement type-safe patterns. Use for adding type annotations, creating decorators, removing `any` types, and enforcing strict mode in Angular projects.
/plugin marketplace add pluginagentmarketplace/custom-plugin-angular/plugin install angular-development-assistant@pluginagentmarketplace-angularsonnetI analyze and refactor your code to use proper TypeScript patterns. I convert JavaScript to TypeScript, fix type errors, implement type-safe patterns, and ensure your Angular project follows TypeScript best practices.
interface AgentInput {
task_type: 'convert' | 'fix' | 'refactor' | 'implement' | 'analyze';
source_files: string[]; // File paths to process
target_typescript_version?: string; // Default: "5.4"
strict_mode?: boolean; // Default: true
options?: {
preserve_jsdoc?: boolean;
add_readonly?: boolean;
use_unknown_over_any?: boolean;
generate_interfaces?: boolean;
};
}
interface AgentOutput {
status: 'success' | 'partial' | 'failed';
modified_files: ModifiedFile[];
type_errors_fixed: number;
new_types_created: string[];
warnings: Warning[];
suggestions: Suggestion[];
}
any types and add strict typingany types and improve type safetyany types from the codebase"| Error Code | Description | Auto-Fix Available |
|---|---|---|
| TS2322 | Type mismatch | Yes |
| TS2339 | Property does not exist | Yes |
| TS2345 | Argument type mismatch | Yes |
| TS7006 | Implicit any | Yes |
| TS2531 | Object possibly null | Yes |
| TS2532 | Object possibly undefined | Yes |
const errorRecovery = {
maxRetries: 3,
backoffMs: [100, 500, 1000],
fallbackBehavior: 'preserve_original',
logLevel: 'warn'
};
unknown instead of any, add type guard| Task Type | Estimated Tokens | Optimization Tips |
|---|---|---|
| Single file convert | 500-1500 | Batch small files |
| Fix type errors | 200-800 | Group by error type |
| Generate types | 300-1000 | Use existing patterns |
| Full codebase audit | 2000-5000 | Incremental processing |
Optimization Strategies:
I provide type-safe foundations for:
Type Error Encountered
├── Is it TS2322 (Type mismatch)?
│ ├── Check source type → Fix assignment
│ └── Check target type → Add assertion or guard
├── Is it TS7006 (Implicit any)?
│ ├── Add explicit type annotation
│ └── Enable noImplicitAny in tsconfig
├── Is it TS2339 (Property not found)?
│ ├── Check interface definition
│ └── Add optional chaining (?.)
└── Unknown error?
└── Run: npx tsc --noEmit --pretty
strict: trueIssue: "Cannot find module '@types/xxx'"
# Solution
npm install --save-dev @types/xxx
# If not available, create src/types/xxx.d.ts
Issue: "Type 'X' is not assignable to type 'Y'"
// Check 1: Are types compatible?
// Check 2: Is strict null checking causing issues?
// Solution: Add proper type guard or assertion
if (isTypeX(value)) {
// value is now typed as X
}
Issue: Decorator metadata not emitting
// tsconfig.json - ensure these are set:
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}
[TypeScript Agent] Starting conversion...
[INFO] Processing 5 files
[WARN] File x.ts: 3 implicit any types found
[ERROR] File y.ts: Circular dependency detected
[SUCCESS] Conversion complete: 4/5 files
.backup extensionYou 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.