Create TypeScript interface types for an API response. Use when adding type definitions for a new resource or endpoint.
Ask the user:
user, order, product)Always fetch the real endpoint before writing types:
# List endpoint
curl <api-base-url>/{resource}s?limit=1 | jq '.'
# Detail endpoint
curl <api-base-url>/{resource}s/{id} | jq '.'
Pay attention to:
nullFile: src/api/types/{resource}.d.ts
Type files contain only interfaces and type aliases — no functions, no constants, no imports.
If the resource shares common shapes (e.g. Pagination, ApiInfo) with other resources, define those in src/api/types/common.d.ts and keep each resource file focused on its own interfaces.
// Main resource interface
export interface {Resource} {
id: number | string;
// Nullable field — the API can return null
description: string | null;
// Optional field — may not be present in the response
extraField?: string;
// Timestamp
updated_at?: string;
// Arrays of primitives
tags?: string[] | null;
// Arrays of objects
related?: {Resource}Ref[];
}
// Nested reference type (if needed)
export interface {Resource}Ref {
id: number;
title: string;
}
// List response wrapper
export interface {Resource}ListResponse {
data: {Resource}[];
// include pagination/info fields matching the actual response
}
// Detail response wrapper
export interface {Resource}DetailResponse {
data: {Resource};
}
// Field returned as null by the API
description: string | null
// Field that may not be present in the response
bio?: string
// Both
avatar?: string | null
import type when importing these interfaces in other filesany — every field must have an explicit typesrc/api/types/{resource}.d.tsImport and use in your code:
import type {
{Resource}ListResponse,
{Resource}DetailResponse,
} from '@/api/types/{resource}.d';
const body: {Resource}ListResponse = await response.json();
Run type check:
npx tsc --noEmit
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer