How to use the TypeScript Type Generator.
Type inference from a small sample cannot establish every possible field. Identify optionality and uncertainty rather than overfitting the sample.
Make the workflow fit your task.
Compare all supplied samples and the stated contract, defining field types and optionality separately. Mark assumptions about unseen values and distinguish an absent property from a present property whose value can be null.
- What you provide
- Sample JSON and field semantics.
- What you get
- Types with optional fields and uncertainty noted.
See the input and the result.
Illustrative input and output · a teaching example, not a live WebAct run
Example input
Infer a TypeScript draft from these samples: {"id":"A1","nickname":"Ada"} and {"id":"B2"}. Do not assume additional fields.Completed example
type UserSample = {
id: string;
nickname?: string;
};
The absent nickname makes it optional in this sample-based draft. The samples do not establish whether null or other fields are allowed by the actual contract.Load this input into the prompt, then copy it to WebAct to try the task. Your result may differ from the illustration.
Decisions and troubleshooting.
Does one sample without a field prove it is always optional?
It suggests missing data is possible in the sample set, but the authoritative contract should determine the final type where available.
Why does the inferred type reject valid production responses?
Review fields and variants absent from the small sample. Sample-based inference cannot establish the complete contract.
Try it with your own source.
Replace the example with your material in the task prompt. Keep the requirements you need, then copy the task into WebAct.
Customize and copy the task ↑