AI Skill Report Card
Generating TypeScript Definitions
Quick Start15 / 15
TypeScript/* eslint-disable */ declare namespace Namespace.Module.Entity { interface Entity { id: number; field: string; created_at: string; updated_at: string; } type CreateEntityParams = Pick<Entity, 'field'>; type UpdateEntityParams = Partial<Pick<Entity, 'field'>>; type EntityQueryStringParams = { page: number; page_size: number; } & Partial<{ search: string; order_by: string; field: string; id: number | number[]; }>; }
Recommendation▾
Remove the progress checklist from workflow - it's redundant and adds clutter
Workflow13 / 15
Progress:
- Collect namespace information
- Get interface name and fields
- Analyze model for nullable fields
- Generate create/update types
- Create query string parameters
- Format final output
Step 1: Gather Information Ask user for:
- Namespace (e.g., "Planejamento.Cadastro.Area")
- Interface name (e.g., "Area")
- Serializer code or field list
- Model code (for nullable field detection)
- Filter configuration (for query params)
Step 2: Parse Serializer Fields
From DRF serializer fields tuple, map to TypeScript types:
id→number- String fields →
string - Boolean fields →
boolean - DateTime fields →
string - ForeignKey fields →
number - Related labels (
field__label) →string
Step 3: Detect Nullable Fields From model definition:
- Fields with
null=True→ add?optional modifier - Fields with
blank=True→ add?optional modifier read_only_fields→ add?optional modifier
Step 4: Generate CRUD Types
TypeScripttype CreateEntityParams = Pick<Entity, 'writable_field1' | 'writable_field2'>; type UpdateEntityParams = Partial<Pick<Entity, 'writable_field1' | 'writable_field2'>>;
Exclude read_only_fields from create/update types.
Step 5: Build Query String Type Base structure:
TypeScripttype EntityQueryStringParams = { page: number; page_size: number; } & Partial<{ search: string; order_by: string; // ... filter fields }>;
Recommendation▾
Consolidate the field mapping information scattered across steps into a single reference table
Examples18 / 20
Example 1: Basic Entity Input:
Pythonclass CargoSerializer(serializers.ModelSerializer): class Meta: model = Cargo fields = ("id", "nome", "codigo", "created_at", "updated_at") read_only_fields = ("id", "created_at", "updated_at")
Output:
TypeScript/* eslint-disable */ declare namespace System.Module.Cargo { interface Cargo { id: number; nome: string; codigo: string; created_at: string; updated_at: string; } type CreateCargoParams = Pick<Cargo, 'nome' | 'codigo'>; type UpdateCargoParams = Partial<Pick<Cargo, 'nome' | 'codigo'>>; }
Example 2: With Nullable Fields and Relations Input:
Python# Model class ReceitaCanalFlash(models.Model): canal = models.ForeignKey(Canal, null=True, blank=True) codigo = models.CharField(max_length=10) # Serializer class CanalFlashSerializer(serializers.ModelSerializer): canal__label = serializers.CharField(source="canal.nome", read_only=True) class Meta: fields = ("id", "canal", "codigo", "canal__label", "created_at") read_only_fields = ("id", "canal__label", "created_at")
Output:
TypeScriptinterface CanalFlash { id: number; canal?: number; canal__label?: string; codigo: string; created_at: string; } type CreateCanalFlashParams = Pick<CanalFlash, 'codigo' | 'canal'>; type UpdateCanalFlashParams = Partial<Pick<CanalFlash, 'codigo' | 'canal'>>;
Example 3: With Filters Input:
Pythonclass CanalFlashFilter(DefaultFilter): search_fields = ["codigo", "descricao"] codigo = filters.CharFilter(lookup_expr="icontains") canal = filters.NumberFilter(method="filter_canal")
Output:
TypeScripttype CanalFlashQueryStringParams = { page: number; page_size: number; } & Partial<{ search: string; order_by: string; codigo: string; canal: number | number[]; id: number | number[]; }>;
Recommendation▾
Add a complete end-to-end example showing the full input (model + serializer + filter) and complete output
Best Practices
- Always start with
/* eslint-disable */ - Use namespace structure:
Module.SubModule.Entity - Make ForeignKey fields optional if
null=Truein model - Include
__labelfields for related data - Map array filters to
number | number[]orstring | string[] - Always include
id,page,page_size,search,order_byin query params
Common Pitfalls
- Don't forget optional modifiers (
?) for nullable model fields - Don't include
read_only_fieldsin create/update types - Don't map Django field types incorrectly (DateTimeField → string, not Date)
- Don't miss array filter syntax for
getlist()methods - Don't forget to ask for complete filter configuration