AI Skill Report Card

Generating TypeScript Models

B+78·May 6, 2026·Source: Web
15 / 15
TypeScript
// Basic model.ts structure import useLoading from '@/hooks/use-loading'; import { message } from 'antd'; import { useState } from 'react'; import { getItemsController, createItemController } from './item.controller'; export default () => { const [items, setItems] = useState([]); const { loading, startLoading, stopLoading } = useLoading(); const getItems = async (...args: Parameters<typeof getItemsController>) => { try { startLoading(); const response = await getItemsController(...args); setItems(response.data); } catch (error) { message.error('Não foi possível obter os dados'); return Promise.reject(); } finally { stopLoading(); } }; return { items, loading, getItems }; };
Recommendation
Reduce verbosity in workflow steps - the explanations are too detailed for concepts Claude already understands
13 / 15

Progress:

  • Analyze controller functions and their parameters
  • Determine data structure (pagination vs array)
  • Generate state management with appropriate type
  • Create CRUD functions matching controller signatures
  • Add error handling with generic messages
  • Return hook interface with camelCase naming

Step 1: Analyze Controllers

Look for controller files (*.controller.ts) and identify available CRUD operations:

  • getXControllergetX function
  • createXControllercreateX function
  • updateXControllerupdateX function
  • deleteXControllerdeleteX function

Step 2: Determine State Structure

With pagination:

TypeScript
const [items, setItems] = useState<App.Pagination<Type>>(defaultPaginationValues);

Without pagination:

TypeScript
const [items, setItems] = useState<Type[]>([]);

Step 3: Generate CRUD Functions

GET function pattern:

TypeScript
const getItems = async (...args: Parameters<typeof getItemsController>) => { try { startLoading(); const response = await getItemsController(...args); const { data } = response; setItems(data); } catch (error) { message.error('Não foi possível obter os dados'); return Promise.reject(); } finally { stopLoading(); } };

CREATE function pattern:

TypeScript
// With pagination setItems((previousData) => ({ ...previousData, results: [data, ...(previousData?.results || [])], count: previousData.count + 1, })); // Without pagination setItems((previousData) => [data, ...previousData]);

UPDATE function pattern:

TypeScript
const nArray = updateArrayItem({ arr: items.results || items, // depends on pagination identification: args[parameterIndex], // check controller signature values: data, targetField: 'id', });

DELETE function pattern:

TypeScript
// With pagination setItems((previousData) => ({ ...previousData, count: previousData.count - 1, results: previousData.results.filter((r) => r.id !== args[parameterIndex]), })); // Without pagination setItems((previousData) => previousData.filter((p) => p.id !== args[parameterIndex]));
Recommendation
Add concrete input/output examples showing actual controller signatures and generated model code
17 / 20

Example 1: With Pagination Controller: getAreasController(qsParams), updateAreaController(id, params)

TypeScript
// args[0] is id for update/delete const nArray = updateArrayItem({ identification: args[0], // ... });

Example 2: With Parameters
Controller: updateItemController(versao, id, params)

TypeScript
// args[1] is id when versao is first parameter const nArray = updateArrayItem({ identification: args[1], // ... });

Example 3: Return Interface

TypeScript
return { itemLoading: loading, items, getItems, createItem, updateItem, deleteItem, };
Recommendation
Include a complete working example from controller analysis to final model.ts file
  • Always use ...args: Parameters<typeof controllerFunction> for function parameters
  • Import only required utilities: defaultPaginationValues, updateArrayItem
  • Use generic error messages without entity names
  • Follow camelCase naming for returned functions and loading states
  • Include count updates for paginated create/delete operations
  • Handle both paginated and non-paginated responses correctly
  • Don't include functions for non-existent controllers
  • Don't hardcode parameter positions - check controller signature
  • Don't use entity-specific error messages
  • Don't forget to update count for paginated operations
  • Don't mix pagination and array patterns
  • Don't include unnecessary imports or complex logic
0
Grade B+AI Skill Framework
Scorecard
Criteria Breakdown
Quick Start
15/15
Workflow
13/15
Examples
17/20
Completeness
16/20
Format
15/15
Conciseness
12/15