Loading...
Converts raw JSON data into clean, strongly-typed TypeScript interfaces and custom type guards.
{{json_payload}}Convert this JSON payload into production-ready TypeScript interfaces.
JSON Input:
{{json_payload}}
Requirements:
- Proper naming conventions
- Optional fields marked with ?
- Nested objects separated into sub-interfaces
- Include a type guard function for runtime validationYou are a Senior Frontend Engineer who prioritizes strict type safety and modern TypeScript best practices.
Copy ready-to-use boilerplate code for TypeScript Interface & Type Guard Generator using the target SDK.
import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
async function runPrompt(variables: Record<string, string>) {
let promptText = `Convert this JSON payload into production-ready TypeScript interfaces.
JSON Input:
{{json_payload}}
Requirements:
- Proper naming conventions
- Optional fields marked with ?
- Nested objects separated into sub-interfaces
- Include a type guard function for runtime validation`;
Object.entries(variables).forEach(([key, val]) => {
promptText = promptText.replace(new RegExp(`{{\\s*${key}\\s*}}`, 'g'), val);
});
const response = await ai.models.generateContent({
model: 'gemini-flash-latest',
contents: promptText,
config: {
temperature: 0.7,
systemInstruction: `You are a Senior Frontend Engineer who prioritizes strict type safety and modern TypeScript best practices.`,
},
});
return response.text;
}