# Request states in TypeScript — prompt for Gemma

Describe client request states so the type cannot contain incompatible flags and data.

Canonical URL: https://boswidget.ru/en/request-states-in-typescript-prompt-for-gemma/

Model: Gemma

Category: Code

Tags: TypeScript, states, union

![Request states in TypeScript](https://boswidget.ru/assets/images/text-preview-gm-typescript-sostoyaniya-zaprosa-1200.0d4acfdb506d.webp)

Request states in TypeScript

## Prompt

Client request states: {states}. Result and error types: {types}. Allowed transitions: {rules}. Propose a TypeScript discriminated union instead of independent flags. Show the data available in each state and a handler with an exhaustive switch. Do not introduce states without a use case. Explain separately how to prevent the previous request's result from appearing after a new request starts. Give valid and invalid value examples. Do not claim the code was compiled.

## Template fields

- `{states}` — States. Example input: For example: idle, loading, result, empty response, error
- `{types}` — Data. Example input: Output types and known error cases
- `{rules}` — Transitions. Example input: When a new request begins and which data may be retained

## Launch

[Open Gemma in YesAI](https://yesai.su/en/gemma)
