| name | goravel-type-check |
| description | Cross-reference Go structs (model, requests) with TypeScript interfaces to verify type consistency, field coverage, nullable handling, and JSON tag alignment. |
| argument-hint | [EntityName] |
| allowed-tools | Read, Grep, Glob |
Go ↔ TypeScript Type Consistency Check
Verify type alignment for $ARGUMENTS.
Files to Cross-Reference
Go (source of truth)
app/models/<entity>.go — Model struct (JSON response shape)
app/http/requests/<entity>_*request.go — Create/Update request structs (API input shape)
TypeScript (must match Go)
resources/js/types/<entity>.ts — Entity interface, CreateData, UpdateData
Frontend consumers (must use correct types)
resources/js/pages/<Entity>/sections/<Entity>CreateForm.tsx
resources/js/pages/<Entity>/sections/<Entity>EditForm.tsx
resources/js/pages/<Entity>/sections/<Entity>DetailView.tsx
resources/js/pages/<Entity>/sections/<Entity>Columns.tsx
Type Mapping Reference
Go → TypeScript Field Types
| Go Type | TypeScript Type | Notes |
|---|
string | string | |
*string | string | undefined or string? | Optional field |
int, uint, int64 | number | |
*int, *uint | number? | Optional |
float64 | number | |
*float64 | number? | Optional |
bool | boolean | |
*bool | boolean? | Optional |
time.Time | string | ISO 8601 / RFC3339 |
*time.Time | string? | Optional date |
carbon.DateTime | string | Audit fields |
[]string | string[] | JSON array |
datatypes.JSON | Record<string, any> or typed interface | JSON object |
JSON Tag → TypeScript Property Name
Go JSON tags determine the API response property names:
Title string `json:"title"`
PublishedAt *time.Time `json:"publishedAt"`
Critical: The TypeScript interface property name must match the Go JSON tag value exactly.
Dual-Case Fields
Some entities need both camelCase and snake_case for compatibility:
publishedAt?: string;
published_at?: string;
Check MarshalJSON() in the Go model to see which case the API actually sends.
Checklist
1. Model → Entity Interface
For each field in the Go model:
2. Create Request → CreateData Interface
For each field in Go CreateRequest:
3. Update Request → UpdateData Interface
For each field in Go UpdateRequest:
4. API Response Consistency
5. Enum Consistency
For each enum/status field:
6. Field Name Mapping (Frontend → API)
Check that forms convert camelCase → snake_case when sending to API:
const [formData, setFormData] = useState<CreateData>({
publishedAt: '',
configType: '',
});
const requestBody = {
published_at: formData.publishedAt,
config_type: formData.configType,
};
7. Nullable Field Handling
Common Type Mismatches
Missing optional marker
Description *string `json:"description"`
description: string;
description?: string;
Wrong enum type
rules["status"] = "in:ACTIVE,INACTIVE,PENDING"
status: string;
status: 'ACTIVE' | 'INACTIVE' | 'PENDING';
Mismatched field name
ConfigType string `json:"configType"`
config_type: string;
configType: string;
Missing audit fields
type Entity struct {
BaseAuditableModel
Name string `json:"name"`
}
interface Entity {
name: string;
}
interface Entity extends BaseModel {
name: string;
}
Output
After review, produce a report with:
- Field-by-field comparison table: Go field → TS field → Match/Mismatch
- Type mismatches: Fields where Go and TS types don't align
- Missing fields: Fields in Go but not in TS (or vice versa)
- Nullable inconsistencies: Required in TS but nullable in Go
- Enum gaps: Enum values in Go validation but missing from TS union
- Form field mapping issues: camelCase/snake_case conversion errors
Reference
- Canonical Go model:
app/models/book.go
- Canonical TS types:
resources/js/types/book.ts
- Canonical Go request:
app/http/requests/book_request.go
- Base model TS:
resources/js/types/crud.ts (BaseModel interface)
- Base Go model:
app/models/base_auditable_model.go (BaseAuditableModel)