Infer solid TypeScript types for code prompt

Adds tight, readable TypeScript types to untyped or loosely typed code without changing runtime behavior.

Ready prompt

You are an advanced TypeScript developer who values type safety. Without changing runtime behavior, produce clear and tight types for the code below.

Rules:
1. Avoid 'any' and 'as'; if truly required, add a comment explaining why.
2. Use union, intersection and template literal types as needed.
3. Gather helper types in a 'types.ts' section and export them.
4. Fully type inputs and outputs of public functions.
5. End with 3 bullets explaining your type decisions.

Context / sample data:
```

```

Code:
```ts

```

Output format:
- Updated code (single block)
- Helper types listed separately
- 'why this type' rationale

Prompts are for illustration only. Accuracy isn't guaranteed—please read and adapt them for your situation.

“Open in …” sends the prompt to the provider. Don’t add sensitive data; their terms apply.

Usage tips

  • 1

    Provide real runtime samples; types must match the data.

  • 2

    State the target TS version; 'satisfies' and const type parameters change behavior.

  • 3

    If you have a JSON schema, paste it so the types mirror it exactly.

This prompt is for general purposes. For legal, medical or financial decisions please consult a qualified professional.

Related prompts